-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
One-time version check #1456
One-time version check #1456
Conversation
Let's do #1296 first and then you can revisit this |
@melange396 since #1296 is merged, we can move forward with this PR; lmk if the current iteration looks good! |
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.
Do yall only need this for internal use? If so, then this is good to go. If not, then we should not hide the version check behind a debug flag.
Co-authored-by: Dmitry Shemetov <dshemetov@ucdavis.edu>
Co-authored-by: Dmitry Shemetov <dshemetov@ucdavis.edu>
Co-authored-by: Dmitry Shemetov <dshemetov@ucdavis.edu>
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.
This functionality has enough purpose (and code!) for it to be in its own method and not taking up >50% of the lines inside the _request()
method.
The intent is for this to be helpful to the user -- without their needing to ask for it -- thus it would be better for the flag/argument to be opt-out instead of opt-in, if we give the option at all.
I had envisioned that we would do this on module load [only once, on the initial load into the namespace]. That might make it hard to do opt-in/out behavior, but it could make for a more natural interaction with the user, especially if they are using it in an interactive environment. What do you think?
src/client/delphi_epidata.py
Outdated
) | ||
except Exception as e: | ||
Epidata.log("Error getting latest client version", exception=str(e)) | ||
_version_check.__func__() # run this once on module load |
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.
In Python <= 3.9, static methods cannot be directly called within the class body.
In Python >= 3.10, it works as you'd expect: _version_check()
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.
_version_check.__func__() # run this once on module load | |
# Run this once on module load. Use dunder method for Python <= 3.9 compatibility | |
# https://stackoverflow.com/a/12718272 | |
_version_check.__func__() |
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.
plz also add newline above function call!
would it be any better/easier to avoid this pattern here and just call Epidata._version_check()
at the end of the file (after the class definition)?
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.
plz also add an entry to CHANGELOG!
src/client/delphi_epidata.py
Outdated
) | ||
except Exception as e: | ||
Epidata.log("Error getting latest client version", exception=str(e)) | ||
_version_check.__func__() # run this once on module load |
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.
plz also add newline above function call!
would it be any better/easier to avoid this pattern here and just call Epidata._version_check()
at the end of the file (after the class definition)?
Co-authored-by: Dmitry Shemetov <dshemetov@ucdavis.edu>
|
Closes #1281
Summary:
Adds a one-time check to the Epidata client, which logs a warning when the current "remote" server version (https://api.delphi.cmu.edu/epidata/version) does not match the client version.
This is limited to debug mode for now but can be easily extended to run by default.
Also adds a test to verify this behavior.
Prerequisites:
dev
branchdev