-
Notifications
You must be signed in to change notification settings - Fork 1
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
Update load_dataframe
#1
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e704015
Update load_dataframe function to force all geos to be defined
peterrrock2 032c43b
Fix pyproject file
peterrrock2 4badd8c
Update load_dataframe to do better validation and give GerrDB a conte…
peterrrock2 556c573
Make some path characters illegal and update TODO
peterrrock2 f2f3c6a
Fix some formatting issues
peterrrock2 aeaed56
Remove some debug print statements
peterrrock2 8ed54a0
Address Anna cosmetic comments
peterrrock2 e15fba0
Fix tests
peterrrock2 1d1824d
Fix workflow file
peterrrock2 dfe5be2
Merge pull request #1 from peterrrock2/bugfix/testworkflow
peterrrock2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,15 +120,18 @@ def update( | |
@online | ||
def set_values( | ||
self, | ||
path_or_col: Union[Column, str], | ||
path: Optional[str], | ||
namespace: Optional[str] = None, | ||
*, | ||
col: Optional[Column] = None, | ||
values: dict[Union[str, Geography], Any], | ||
) -> None: | ||
"""Sets the values of a column on a collection of geographies. | ||
|
||
Args: | ||
path_or_col: Short identifier for the column or a `Column` metadata object. | ||
path: Short identifier for the column. Only this or `col` should be provided. | ||
col: `Column` metadata object. If the `path` is not provided, the column's | ||
path will be used. | ||
namespace: Namespace of the column (used when `path_or_col` is a raw path). | ||
values: | ||
A mapping from geography paths or `Geography` metadata objects | ||
|
@@ -137,7 +140,14 @@ def set_values( | |
Raises: | ||
RequestError: If the values cannot be set on the server side. | ||
""" | ||
path = path_or_col.path if isinstance(path_or_col, Column) else path_or_col | ||
|
||
assert path is None or isinstance(path, str) | ||
assert col is None or isinstance(col, Column) | ||
|
||
if path is None and col is None: | ||
raise ValueError("Either `path` or `col` must be provided.") | ||
|
||
path = col.path if col is not None else path | ||
|
||
response = self.ctx.client.put( | ||
f"{self.base_url}/{namespace}/{path}", | ||
|
@@ -163,16 +173,19 @@ def set_values( | |
@online | ||
async def async_set_values( | ||
self, | ||
path_or_col: Union[Column, str], | ||
path: Optional[str], | ||
namespace: Optional[str] = None, | ||
*, | ||
col: Optional[Column] = None, | ||
values: dict[Union[str, Geography], Any], | ||
client: Optional[httpx.AsyncClient] = None, | ||
) -> None: | ||
"""Asynchronously sets the values of a column on a collection of geographies. | ||
|
||
Args: | ||
path_or_col: Short identifier for the column or a `Column` metadata object. | ||
path: Short identifier for the column. Only this or `col` should be provided. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, pls clarify behavior for different combinations of path or col provided |
||
col: `Column` metadata object. If the `path` is not provided, the column's | ||
path will be used. | ||
namespace: Namespace of the column (used when `path_or_col` is a raw path). | ||
values: | ||
A mapping from geography paths or `Geography` metadata objects | ||
|
@@ -183,31 +196,38 @@ async def async_set_values( | |
Raises: | ||
RequestError: If the values cannot be set on the server side. | ||
""" | ||
path = path_or_col.path if isinstance(path_or_col, Column) else path_or_col | ||
assert path is None or isinstance(path, str) | ||
assert col is None or isinstance(col, Column) | ||
|
||
if path is None and col is None: | ||
raise ValueError("Either `path` or `col` must be provided.") | ||
|
||
path = col.path if col is not None else path | ||
|
||
ephemeral_client = client is None | ||
if ephemeral_client: | ||
params = self.ctx.client_params.copy() | ||
params["transport"] = httpx.AsyncHTTPTransport(retries=1) | ||
client = httpx.AsyncClient(**params) | ||
|
||
json = [ | ||
ColumnValue( | ||
path=( | ||
f"/{geo.namespace}/{geo.path}" | ||
if isinstance(geo, Geography) | ||
else geo | ||
), | ||
value=_coerce(value), | ||
).dict() | ||
for geo, value in values.items() | ||
] | ||
response = await client.put( | ||
f"{self.base_url}/{namespace}/{path}", | ||
json=[ | ||
ColumnValue( | ||
path=( | ||
f"/{geo.namespace}/{geo.path}" | ||
if isinstance(geo, Geography) | ||
else geo | ||
), | ||
value=_coerce(value), | ||
).dict() | ||
for geo, value in values.items() | ||
], | ||
json=json, | ||
) | ||
|
||
if response.status_code != 204: | ||
log.debug(f"For {path_or_col} returned {response}") | ||
log.debug(f"For path = {path} and col = {col} returned {response}") | ||
|
||
response.raise_for_status() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,19 +6,19 @@ authors = ["Parker J. Rule <[email protected]>"] | |
|
||
[tool.poetry.dependencies] | ||
python = "^3.9" | ||
tomlkit = "^0.11.6" | ||
msgpack = "^1.0.4" | ||
httpx = "^0.23.3" | ||
tomlkit = "^0.13.0 | ||
msgpack = "^1.1.0" | ||
httpx = "^0.27.2" | ||
pydantic = "^1.10.4" | ||
orjson = "^3.8.6" | ||
orjson = "^3.10.0" | ||
shapely = "^2.0.1" | ||
python-dateutil = "^2.8.2" | ||
geopandas = "^0.12.2" | ||
geopandas = "^1.0.1" | ||
networkx = "^3.0" | ||
|
||
[tool.poetry.group.dev.dependencies] | ||
pytest = "^7.2.1" | ||
black = "^23.1.0" | ||
black = "^24.8.0" | ||
pytest-vcr = "^1.0.2" | ||
|
||
[tool.isort] | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can you update this comment about the behavior of the function when both path and col are passed?