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

feat(py client): read from DELPHI_EPIDATA_KEY #1231

Closed
wants to merge 1 commit into from
Closed

Conversation

dshemetov
Copy link
Contributor

This should make CI integrations easier, by allowing us to set the env var to a secret. Also mimics behavior in epidatr.

Summary:

  • read API key from DELPHI_EPIDATA_KEY env var by default, else None

Prerequisites:

  • Unless it is a documentation hotfix it should be merged against the dev branch
  • Branch is up-to-date with the branch to be merged with, i.e. dev
  • Build is successful
  • Code is cleaned up and formatted

@sonarcloud
Copy link

sonarcloud bot commented Jul 11, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dshemetov dshemetov requested a review from krivard July 11, 2023 23:03
@krivard
Copy link
Contributor

krivard commented Jul 11, 2023

see #1232 (review)

Copy link
Collaborator

@melange396 melange396 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the motivation is to be able to provide a secret API Key for CI tests, theres no need: those tests dont use production data or services, and we can insert any old "test" key into the local test database during the pre-test setups. (like here)

for other purposes, id shy away from using the environment variable for the API Key... imnsho, users of the python client library should assign the key in their code, or they can pull the value from something external themselves.

@@ -45,7 +46,7 @@ class Epidata:

# API base url
BASE_URL = "https://api.delphi.cmu.edu/epidata/api.php"
auth = None
auth = os.environ.get("DELPHI_EPIDATA_KEY")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not obvious (though it should be made clearer (probbly with a setter method)), but this variable should be assigned a 2-tuple of the username "epidata" followed by the key (or the var can be set to a different Auth-like object, but thats a longer story) -- a plain string will not work. see covidcast/covidcast.py for a reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yea Minh and I ran into this earlier

@dshemetov
Copy link
Contributor Author

No need

@dshemetov dshemetov closed this Jul 13, 2023
@dshemetov dshemetov deleted the ds/auth branch July 13, 2023 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants