Pytask unusable
catchthemonster opened this issue · 1 comments
firetask2 = Firework(PyTask(func='time.sleep',args=[5]))
fw = Firework([firetask2])
store workflow and launch it locally, single shot
launchpad.add_wf(fw)
launch_rocket(launchpad, FWorker())
would not run...
I traced it to recursive serialize and bellow is my changed input to validate list or dict objects...
Launchpad is not happy now but I need input from someone to understand overall architecture to fix this ...
I am using latest 1.9.8 FW mongodb is 5.x rh8 and py3.10.0
PyTask is definitely failing here:
self.fireworks.find_one_and_replace({‘fw_id’: fw.fw_id},
fw.to_db_dict(),
upsert=True)
so:
def to_dict(self):
…
spec[’_tasks’] = [t.to_dict() for t in self.tasks]
t is already a dict and spec[’_tasks’] is trying to convert dict to dict failing miserably …
{‘spec’: {’_tasks’: [:{‘func’: ‘time.sleep’, ‘args’: [5], ‘_fw_name’: ‘PyTask’}]}, ‘fw_id’: -1, ‘created_on’: datetime.datetime(2022, 1, 16, 20, 20, 16, 789436), ‘updated_on’: datetime.datetime(2022, 1, 16, 20, 20, 16, 789437), ‘name’: ‘Unnamed FW’}
so I changed this code to debug a bit:
@recursive_serialize
def to_dict(self):
put tasks in a special location of the spec
spec = self.spec
spec[’_tasks’] = list()
for t in self.tasks:
print(t)
if isinstance(t, dict):
spec[’_tasks’].append(t)
else:
td = t.to_dict()
spec[’_tasks’].append(td)
##spec['_tasks'] = [t.to_dict() for t in self.tasks]
m_dict = {'spec': spec, 'fw_id': self.fw_id, 'created_on': self.created_on,
'updated_on': self.updated_on}
# only serialize these fields if non-empty
if len(list(self.launches)) > 0:
m_dict['launches'] = self.launches
if len(list(self.archived_launches)) > 0:
m_dict['archived_launches'] = self.archived_launches
# keep export of new FWs to files clean
if self.state != 'WAITING':
m_dict['state'] = self.state
m_dict['name'] = self.name
return m_dict
Now firework is working correctly, meaning rocket can finish…
problem at this point is:
2022-01-16 15:28:50,762 INFO Rocket finished
Traceback (most recent call last):
File “/cube/api/py-3.9.7/lib/python3.9/site-packages/fireworks/core/rocket.py”, line 248, in run
l_logger.log(logging.INFO, "Task started: s. t.fw_name)
AttributeError: ‘dict’ object has no attribute ‘fw_name’
Ether documentation is not correctly addressing invocation of PyTask, or launchpad is not treating it correctly...
rocket is actually failing and i think that task is fizzled at the end...
You might consider asking this on matsci.org, it's our forum and others might be able to help you!