Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotImplementedError XML #792

Open
mchoccie opened this issue Nov 8, 2024 · 8 comments
Open

NotImplementedError XML #792

mchoccie opened this issue Nov 8, 2024 · 8 comments

Comments

@mchoccie
Copy link

mchoccie commented Nov 8, 2024

Hello,

I try to run the "mlg_wb_solution.py" file provided in the tutorial but got the following errors. Can you tell me how to fix it? Thanks.

It would really help to have this fixed because then I'd be able to create custom environments in the newer version which is much easier to interface with.

Traceback (most recent call last):
File "/root/minerRL/renderGame.py", line 83, in
obs = env.reset()
File "/usr/local/lib/python3.10/dist-packages/gym/wrappers/time_limit.py", line 27, in reset
return self.env.reset(**kwargs)
File "/usr/local/lib/python3.10/dist-packages/minerl/env/_singleagent.py", line 22, in reset
multi_obs = super().reset()
File "/usr/local/lib/python3.10/dist-packages/minerl/env/_multiagent.py", line 433, in reset
agent_xmls = self._setup_agent_xmls(ep_uid)
File "/usr/local/lib/python3.10/dist-packages/minerl/env/_multiagent.py", line 481, in _setup_agent_xmls
xml_in = self.task.to_xml()
File "/usr/local/lib/python3.10/dist-packages/minerl/herobraine/env_spec.py", line 269, in to_xml
xml = template.render(var_dict)
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 1291, in render
self.environment.handle_exception()
File "/usr/lib/python3/dist-packages/jinja2/environment.py", line 925, in handle_exception
raise rewrite_traceback_stack(source=source)
File "", line 72, in top-level template code
File "/usr/local/lib/python3.10/dist-packages/minerl/herobraine/env_spec.py", line 292, in get_consolidated_xml
handler_xml_strs = [handler.xml() for handler in handlers]
File "/usr/local/lib/python3.10/dist-packages/minerl/herobraine/env_spec.py", line 292, in
handler_xml_strs = [handler.xml() for handler in handlers]
File "/usr/local/lib/python3.10/dist-packages/minerl/herobraine/hero/handler.py", line 58, in xml
template = env.from_string(self.xml_template())
File "/usr/local/lib/python3.10/dist-packages/minerl/herobraine/hero/handler.py", line 42, in xml_template
raise NotImplementedError()
NotImplementedError

@Miffyli
Copy link
Contributor

Miffyli commented Nov 12, 2024

Hey @mchoccie, sorry for the delay, been offline.

Where is this tutorial file from? That is not from the original MineRL repo unless it is somewhere deeper down which I have forgotten. Unfortunately we do not have time for custom tech support.

Did you manage to install the environment? Looking at your other messages, it seems like you got some errors while installing the environment. Please share the full installation log. In future, submitting one message will suffice :)

@mchoccie
Copy link
Author

mchoccie commented Nov 14, 2024

Hey @Miffyli, thanks for responding. I got everything installed and working. I even fixed an issue relating to the XML_Templating in the code so I may create a pull request. It's a small fix. My new issue is, I wish to customize the "treechop_specs.py" file so that I can get a reward of 50 for mining 1 log (This is the MineRLTreechop-v0 environment). Here is the code I'm trying to alter in the repository:

image
(I changed the amount from 64 to 1)

I rebuilt the library with these changes using "pip install .". The only issue is I can't see any reward received for mining simply one log despite these changes. Is there something deeper I need to change?

Thanks for your help.

@Miffyli
Copy link
Contributor

Miffyli commented Nov 14, 2024

The current code is """bit""" confusing mess of older, obsolete pieces of code mixed with new one that functions (i.e., it was hacked up to the current state with only focus on the 2022 competition requirements). I do not think Treechop ever got updated to the new standard.

Take a look at the ObtainDiamondShovel task instead and how it is implemented now, where the reward logic has to be done manually: https://github.com/minerllabs/minerl/blob/dev/minerl/herobraine/env_specs/obtain_specs.py (I do not think the RewardForCollectingItems was ever implemented for this newer version of MineRL)

@valdosys
Copy link

valdosys commented Nov 16, 2024

@mchoccie I also encountered the issue with the XML_Templating. Could you please tell me how you fixed it?

@mchoccie
Copy link
Author

Hey @valdosys I just created a pull request for this repository. If you look at my pull request you can see which file and line I had to change to resolve the issue. Effectively, all the handlers were inheriting a function called XML_Template from a parent handler class. Yet in one of the child handlers the function was overridden but named XML_Element for some reason. Hope this helps!

@valdosys
Copy link

Great! You’re a lifesaver! :)

Did you also encounter the TypeError: a bytes-like object is required, not 'NoneType'-error when running (since you also wanted to test this tutorial with the MLG jump)?

@mchoccie
Copy link
Author

@valdosys Yes I did the issue I believe stems from one of the handlers in the MLG jump scenario. I can't clearly remember which one it was now but I tested commenting each handler out individually and it eventually worked. This solution might seem kind of hacky, but to fix this problem I think (big emphasis on think, because I'm not entirely sure) requires tinkering with the Java codebase somehow

@Miffyli
Copy link
Contributor

Miffyli commented Nov 19, 2024

@valdosys The error TypeError: a bytes-like object is required, not 'NoneType usually means MineRL was not installed correctly (most often scenario where you see it). Look at the full trace to get better understanding what might be wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants