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

use socrata connector, auth for ingest/library calls #1312

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

fvankrieken
Copy link
Contributor

@fvankrieken fvankrieken commented Dec 9, 2024

Meant to close #1311

Seems that some dot datasets went private, meaning we can't simply download them without auth

2 commits just to make changes easier to see (1 just moves some logic, 2 makes needed changes)

passing run here

@fvankrieken fvankrieken force-pushed the fvk-socrata-auth-extract branch 9 times, most recently from 00b5419 to 73bc340 Compare December 9, 2024 22:14
@fvankrieken fvankrieken marked this pull request as ready for review December 9, 2024 22:14
@fvankrieken fvankrieken force-pushed the fvk-socrata-auth-extract branch from 73bc340 to f495074 Compare December 9, 2024 22:21
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 15 lines in your changes missing coverage. Please review.

Project coverage is 70.51%. Comparing base (e2f01fc) to head (c589be0).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dcpy/connectors/socrata/publish.py 18.18% 9 Missing ⚠️
dcpy/library/config.py 69.23% 3 Missing and 1 partial ⚠️
dcpy/connectors/socrata/utils.py 85.71% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1312      +/-   ##
==========================================
+ Coverage   70.41%   70.51%   +0.09%     
==========================================
  Files         114      115       +1     
  Lines        6129     6129              
  Branches      700      700              
==========================================
+ Hits         4316     4322       +6     
+ Misses       1669     1662       -7     
- Partials      144      145       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

SOCRATA_PASSWORD = os.getenv("SOCRATA_PASSWORD")


def _simple_auth():
Copy link
Contributor

Choose a reason for hiding this comment

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

can we move this and _socrata_request() to some utils ile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup

@sf-dcp
Copy link
Contributor

sf-dcp commented Dec 10, 2024

LGTM! The only rec is to move helper functions out of the init file

@fvankrieken fvankrieken force-pushed the fvk-socrata-auth-extract branch from f495074 to 05461a3 Compare December 10, 2024 15:28
SOCRATA_PASSWORD = os.getenv("SOCRATA_PASSWORD")


def _simple_auth() -> tuple[str, str] | None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would think we'd want to throw an exception if _simple_auth() is called without these vars present. Any reason not to? (IIRC the Socrata request would fail in that case, even for public resources)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Going with no auth is fine for get requests for things like metadata or pulling datasets

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it makes sense to try to use auth when user/pass is defined, and let failures occur when a resource isn't allowed for a given user (or None auth).

Arguably then, maybe we only call simple_auth if those are defined. But I thought this was simple - get optional auth credentials if available.

Copy link
Contributor

Choose a reason for hiding this comment

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

gotcha, so you've tested that this works for public resources when there are no creds defined? (for some reason I remember that failing, but that was a long time ago.) Maybe it makes sense to just log a warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup - just ran locally with no issue

Copy link
Contributor

@alexrichey alexrichey left a comment

Choose a reason for hiding this comment

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

cool - had one question, but this looks good

@fvankrieken fvankrieken force-pushed the fvk-socrata-auth-extract branch from 05461a3 to c589be0 Compare December 12, 2024 15:25
@fvankrieken fvankrieken merged commit 31cce05 into main Dec 12, 2024
19 of 20 checks passed
@fvankrieken fvankrieken deleted the fvk-socrata-auth-extract branch December 12, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Scheduled Action Failure - Ingest - 📁 Open Data Routine Updates
4 participants