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

duration options seem to be strings sometimes #1389

Open
reidsunderland opened this issue Feb 26, 2025 · 3 comments
Open

duration options seem to be strings sometimes #1389

reidsunderland opened this issue Feb 26, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@reidsunderland
Copy link
Member

This plugin: https://github.com/MetPX/sarracenia/blob/development/sarracenia/flowcb/poll/airnow.py

Doesn't work because self.o.scheduled_interval is a string, when the config has scheduled_interval 900.

I added a line to print the value and type:

[DEBUG] poll.airnow poll sleep is 900 <class 'str'>

I tried setting it to 900s, but that didn't work either:

[DEBUG] poll.airnow poll sleep is 900s <class 'str'>

I don't understand why this isn't causing problems anywhere else.

@reidsunderland reidsunderland added the bug Something isn't working label Feb 26, 2025
@reidsunderland
Copy link
Member Author

I think it likely has something to do with the order that plugins are loaded in.

It looks like the poll plugin is loaded before the scheduled plugin, and that's where the scheduled_interval option is defined as a duration type.

16:41:29,776 [DEBUG] sarracenia.flow run callbacks loaded: ['sarracenia.flowcb.post.message.Message', 'sarracenia.flowcb.gather.message.Message', 'sarracenia.flowcb.retry.Retry', 'sarracenia.flowcb.housekeeping.resources.Resources', 'sarracenia.flowcb.nodupe.disk.Disk', 'poll.airnow', 'log', 'sarracenia.flowcb.scheduled.poll.Poll']

@reidsunderland
Copy link
Member Author

I tried adding a constructor to the airnow poll plugin with self.o.add_option('scheduled_interval', kind='duration') and it doesn't help.

But I am sure that inside the actual scheduled code (https://github.com/MetPX/sarracenia/blob/development/sarracenia/flowcb/scheduled/__init__.py), it is not a string.

I see 2025-02-26 16:49:42,855 [DEBUG] sarracenia.config add_option 29 scheduled_interval declared as type:<class 'float'> value:900s in the logs.

And [DEBUG] sarracenia.flowcb.scheduled calc_next_gather_time next gather should be in 900.0s, scheduled for 2025-02-26 17:04:42.893077+00:00 which should say 900ss if scheduled_interval was a string there.
https://github.com/MetPX/sarracenia/blob/development/sarracenia/flowcb/scheduled/__init__.py#L140

@reidsunderland
Copy link
Member Author

I added a call to durationToSeconds in the plugin as a workaround for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant