-
Notifications
You must be signed in to change notification settings - Fork 3
Feature/threading #35
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
base: main
Are you sure you want to change the base?
Conversation
…hinking about how best to wrap the HTTP calls
… requests. Some errors remain - testing required.
…queue/threading instead of asyncio
… Remove direct python reference in swt run script.
…part of the class/self. Moved queue/threads to AFTER the Value call but before the report execution. Fixed the problem!
…. Make a few corrections from when they got moved around (accidental enter keys)
…r repgen CDA calls and includes tests for parallel. Locked test form date to ensure expected output should always be the same.
DanielTOsborne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The actual threading code seems mostly fine, aside from one section I added a prior comment to, there's just a lot of unrelated changes and questions.
| } | ||
|
|
||
| # This isn't thread safe, not an issue yet though since repgen isn't multithreaded. | ||
| _conn = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still used? The comment was removed, but the variable itself wasn't. If this is still used, is it threadsafe now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable is a _ meaning it should be private if such a scope existed for python
The way I did the threads each of the Value classes spawns it's own call for data. This means the scope is limited for threading to each Value class.
This was just an oversight after all those changes and I missed this comment.
| python-dateutil==2.8.2 | ||
| pytz==2024.1 | ||
| coverage==5.4 | ||
| pytz==2022.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was pytz downgraded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was running the freeze in the wrong environment and this is me reverting those extra changes.
I also noticed there were at least two requirements files in the project. Had to make sure not to overwrite those or get them confused.
Might we work checking to see what the version was prior because the line is not green/red meaning I think that's what it was before? I could be wrong there though
I.e. hasn't been updated since 2022.1 ?
…. Correct issue where queue workers were not properly being released. Pass parallel flag to Report to prevent queue waiting for jobs that don't exist.
…dition with Value that rely on each other
|
@jbkolze downloaded the branch and did some testing. Right out of the gate he realized the threads were not actually doing anything... However, there is one looming issue. I spent some time trying to solve it. This branch is not production ready without this bug fixtldr; race conditions are hard! Currently you are able to re-use Value calls, and this seemingly works. For example if you do: _value = Value(
dbtype="radar",
DBLOC="KEYS",
DBPAR="Elev",
DBPTYP="Inst",
DBINT="1Hour",
DBDUR="0",
DBVER="Ccp-Rev",
DBUNITS="ft",
)This will write the values to the form output Then if you chain another and change just the project for example _value = Value(
DBLOC="FGIB"
)Then this will also write values the correct values to the form. So it seems the The problem arises when you want to take the results of some value and feed that into another Value constructor. For example: _value = Value(
DBLOC="FGIB"
)
_dates = Value(_value.datatimes(),
PICTURE="%d%b%Y %K%M",
) This will end up failing because Some thoughts I had on how to deal with this:
I'm moving on to the other pressing issues - but will revisit this time willing! |
|
Okay, so there are 2 ways (well, maybe more but I can only think of 2) to deal with this chicken and egg problem.
After typing that, they aren't really mutually exclusive. Using more of a builder pattern (factory method, actual class, etc) we could just initialize the object with the query parameters and another call is required to actually get them. However, consider that will add some complexity to people getting onboarded. Honestly I think I like the idea of method that takes multiple definitions and when it returns the data is ready. Seems like explaining "set all your data, then do math" is easier to explain than the intricacies of threading issues. |
Seems #21 is right in line with what you suggest here. |
Added optional flag
-por--parallelto enable multi-threaded CDA fetch requests. This can drop run times significantly since CDA requests are I/O bound and not CPU bound (i.e. waiting on the database/network).What
-pflag is not provided-pflag and compares against an expected output (set datetime) / Add this to the github workflowrepgen/__init__.pyWhy
Bumped version to
5.1.0Issue(s)