-
Notifications
You must be signed in to change notification settings - Fork 130
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
Add reward
and observation
arguments to env.reset()
#451
Comments
I prefer Quote Zen of Python:
It's already unclear to me if these two are strictly equivalent:
vs
Make |
Tbh I think that the solution may be to remove the >>> env.benchmark = "benchmark://foo-v0/abc"
>>> print(env.benchmark)
"benchmark://bar-v0/def" # wtf!
>>> env.reset()
>>> print(env.benchmark)
"benchmark://foo-v0/abc" Another problem with the setters is that they make it harder to debug subtle typos in your code: >>> env.benchmrak = "benchmark://foo-v0/abc"
>>> env.reset()
>>> print(env.benchmark)
"benchmark://bar-v0/def" # wtf! whereas a typo in an argument name will raise an error. I suppose this could be mitigated by having the Same goes for What do you think? Cheers, |
Yes, I actually agree with removing setters for Additionally we want to better differentiate "don't change something when reset" vs "remove something when reset'". e.g. |
👍
That's a very good point! I think it may be worth defining a custom type specifically for this purpose to denote "use whatever value is already set". That would make the default values easier to understand than env.reset(
benchmark=compiler_gym.ValueNotChanged,
reward_space="some_new_space",
observation_space=None, # no observations
) Cheers, |
This seems good to me. Alternatively, we could use python's ellipsis |
Hi @ChrisCummins,
already works, then why not just add a new argument in the function and put the first line in the function body ? Something like,
and then copy the rest of the function below it, and let it run its normal course of actions. |
Great, thanks!
Yes, your suggestion should work. A few other things to consider though:
Cheers, |
I'm also not sure I like the default being the string I would suggest adding a new enum to compiler_gym/util/gym_type_hints.py from enum import Enum
class OptionalArgumentValue(Enum):
UNCHANGED = 1 The if reward_space != OptionalArgumentValue.UNCHANGED:
... Cheers, |
Modified the env.reset() function to add the reward_space and observation_space parameters. Modified the reset() func of the subclasses. Added a OptionalArgumentValue class in gym_type_hints.py for the default value.
Modified the env.reset() function to add the reward_space and observation_space parameters. Modified the reset() func of the subclasses. Added a OptionalArgumentValue class in gym_type_hints.py for the default value.
This adds docstrings to cover the new reward_space and observation_space arguments to reset(). Fixes facebookresearch#451.
🚀 Feature
The CompilerEnv constructor accepts a pair of arguments
reward_space
andobservation_space
. We should add those toenv.reset()
, same as specifying the benchmark.Motivation
Because this feels like a clumsy API:
Pitch
Allow:
The text was updated successfully, but these errors were encountered: