Open krosenmann opened 1 month ago
Thank you for reporting this issue. I'll look into this later today.
JSONSerializer()
is not necessary to reproduce this, nor is Postgres:
>>> data_store = SQLAlchemyDataStore(engine_or_url="sqlite:///example.db")
>>> scheduler = await AsyncScheduler(data_store=data_store).__aenter__()
>>> schedule = await scheduler.add_schedule(task, id='this-is-the-end', trigger=CronTrigger.from_crontab('* * * * *'))
>>> await scheduler.pause_schedule(id='this-is-the-end')
Traceback (most recent call last):
[ truncated ]
AttributeError: year
Pausing the schedule is not necessary either:
>>> data_store = SQLAlchemyDataStore(engine_or_url="sqlite:///example.db")
>>> scheduler = await AsyncScheduler(data_store=data_store).__aenter__()
>>> schedule_id = await scheduler.add_schedule(task, id='this-is-the-end', trigger=CronTrigger.from_crontab('* * * * *'))
>>> schedule = await scheduler.get_schedule(schedule_id)
>>> attrs.asdict(schedule)
Traceback (most recent call last):
[ truncated ]
AttributeError: year
>>> attrs.asdict(schedule.trigger)
Traceback (most recent call last):
[ truncated ]
AttributeError: year
>>> attrs.asdict(CronTrigger.from_crontab("* * * * *"))
{'year': None, 'month': '*', 'day': '*', [ truncated ] }
>>> schedule.trigger
CronTrigger(year='*', month='*', day='*', week='*', day_of_week='*', hour='*', minute='*', second='0', start_time='2024-06-07T10:33:22.438244-04:00', timezone='America/Toronto')
>>> CronTrigger.from_crontab("* * * * *")
CronTrigger(year='*', month='*', day='*', week='*', day_of_week='*', hour='*', minute='*', second='0', start_time='2024-06-07T10:58:40.501026-04:00', timezone='America/Toronto')
It's not clear why attrs
can serialize CronTrigger.from_crontab("* * * * *")
but not schedule.trigger
It's not clear why attrs can serialize CronTrigger.from_crontab(" *") but not schedule.trigger
Try serializing ,deserializing and then serializing it again.
@agronholm Good idea
>>> s = PickleSerializer()
>>> attrs.asdict(s.deserialize(s.serialize(CronTrigger.from_crontab("* * * * *"))))
Traceback (most recent call last):
[ truncated ]
AttributeError: year
>>> attrs.asdict(CronTrigger.from_crontab("* * * * *"))
{'year': None, 'month': '*', 'day': '*', [ truncated ] }
The crux of the problem here is that these virtual fields are only used for initialization, and are not separately saved during serialization, or restored during deserialization.
@WillDaSilva would like to take a shot at fixing the issue, or should I?
@agronholm I could probably address this within a week or two, but if you'd like this resolved promptly it'd be best if you take care of it. This issue isn't affecting me personally. I only jumped in initially because of the possibility that this had something to do with the pause schedule feature.
I only jumped in initially because of the possibility that this had something to do with the pause schedule feature.
Yeah, it certainly doesn't. I'm busy for the next couple of days but I can take care of this later this week.
Things to check first
[X] I have checked that my issue does not already have a solution in the FAQ
[X] I have searched the existing issues and didn't find my bug already reported there
[X] I have checked that my bug is still present in the latest release
Version
4.0.0a5
What happened?
Hi! When I try to pause schedule of a task, created with cron trigger, I'm getting following error. Do you have any advice or workaround maybe for this kind of event? Thanks!
Environment:
The error itself:
How can we reproduce the bug?
Following code reproduces bug