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

Add custom error handling for API errors #205

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

jm-rivera
Copy link

@jm-rivera jm-rivera commented Dec 6, 2024

Note:
First PR in the stack: #202
Second PR in the stack: #203
Previous PR in the stack: #204
Next PR in the stack: #206

Will manually rebase as PRs in the stack are merged to make it easier to review the changes introduced in this PR.


This PR implements custom error handling for API errors. It also includes the related tests.
A bit unrelated but for housekeeping, the imports throughout the module are now passed through isort with Google profile for consistent ordering.

Error Handling:

Adds minimal structure within a new client folder
Adds:
- A Node dataclass which models an individual node (with dcid, name, etc)
- A NodeGroup dataclass which represents a list of Node objects
- An Arcs dataclass, which represents arcs (with a label and containing NodeGroups)
- A Properties dataclass which represents a list of Properties
Adds:
- An Observation dataclass which models an individual observation (date, value)
- An OrderedFacets dataclass which models the 'ordered facets' of observations
- A Variable dataclass which represents a variable data (grouped by entity)
- A Facet class which represents the metadata for a facet
Adds:
- A candidate dataclass to model candidates in the response (with dcid and dominanType)
- An Entity dataclass to model entities with their resolution candidates
Adds:
- A Cell dataclass to model a single cell in a row
- A Row modelling a row with cells.
Adds tests for node, observation, resolve and sparql models.
DCResponse just wraps around the api response
isort imports with google profile
@jm-rivera jm-rivera requested a review from beets December 6, 2024 09:15
@jm-rivera jm-rivera self-assigned this Dec 6, 2024
Copy link

google-cla bot commented Dec 6, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@@ -0,0 +1,78 @@
from typing import Optional
Copy link

Choose a reason for hiding this comment

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

Nit: typo in the filename

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.

2 participants