-
Notifications
You must be signed in to change notification settings - Fork 17
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
stripped tasks can't be pickled #1350
Comments
even more minimal: from predicators.envs import create_new_env
from predicators import utils
from predicators.structs import Task, DefaultState
import dill as pkl
utils.reset_config({"num_train_tasks": 1})
env = create_new_env("blocks", do_cache=True)
train_tasks = env.get_train_tasks()
task = train_tasks[0]
stripped_task = Task(DefaultState, set(task.goal))
with open("/tmp/test.pkl", "wb") as f:
pkl.dump(stripped_task, f)
with open("/tmp/test.pkl", "rb") as f:
pkl.load(f) where the key thing is |
circumventing tasks completely, still crashes! from predicators.envs import create_new_env
from predicators import utils
import dill as pkl
utils.reset_config({"num_train_tasks": 1})
env = create_new_env("blocks", do_cache=True)
train_tasks = env.get_train_tasks()
task = train_tasks[0]
stripped_goal = set(task.goal)
with open("/tmp/test.pkl", "wb") as f:
pkl.dump(stripped_goal, f)
with open("/tmp/test.pkl", "rb") as f:
pkl.load(f) |
this one doesn't crash, so I guess there is some difference between the train tasks created by the environment and the one that I'm creating here? from predicators.structs import Predicate, Type, State, Task
import dill as pkl
type1 = Type("type1", ["feat1", "feat2"])
obj3 = type1("obj3")
obj7 = type1("obj7")
state = State({
obj3: [1, 2],
obj7: [3, 4],
})
cup_type = Type("cup_type", ["feat1"])
plate_type = Type("plate_type", ["feat1"])
pred = Predicate("On", [cup_type, plate_type], lambda s, o: True)
pred2 = Predicate("On", [cup_type, plate_type], lambda s, o: False)
cup = cup_type("cup")
plate = plate_type("plate")
goal = {pred([cup, plate])}
task = Task(state, goal)
stripped_goal = set(task.goal)
with open("/tmp/test.pkl", "wb") as f:
pkl.dump(stripped_goal, f)
with open("/tmp/test.pkl", "rb") as f:
pkl.load(f) |
this is some pretty weird shit, I really don't know... @ronuchit want a Python puzzle? from predicators.envs import create_new_env
from predicators import utils
import dill as pkl
utils.reset_config({"num_train_tasks": 1})
env = create_new_env("blocks", do_cache=False)
train_tasks = env.get_train_tasks()
task = train_tasks[0]
bad_atom = next(iter(task.goal))
block1 = env._block_type("block2")
block2 = env._block_type("block1")
fine_atom = env._On([block1, block2])
_ = hash(fine_atom)
# Succeeds
assert fine_atom == bad_atom
# Nothing discernably different
for field in dir(fine_atom):
print(field)
print("FINE:")
print(getattr(fine_atom, field))
print("BAD:")
print(getattr(bad_atom, field))
# Succeeds
with open("/tmp/test.pkl", "wb") as f:
pkl.dump(fine_atom, f)
with open("/tmp/test.pkl", "rb") as f:
pkl.load(f)
# Fails on load (AttributeError: 'GroundAtom' object has no attribute 'predicate')
with open("/tmp/test.pkl", "wb") as f:
pkl.dump(bad_atom, f)
with open("/tmp/test.pkl", "rb") as f:
pkl.load(f) |
i do not know sorry! it really depends on what's happening inside get_train_tasks |
@ashayathalye ran into a similar issue and realized that it's likely related to some of these: |
to reproduce:
Leads to:
The text was updated successfully, but these errors were encountered: