-
Notifications
You must be signed in to change notification settings - Fork 54
AV2 - Misc functions #986
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
Merged
Merged
AV2 - Misc functions #986
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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 hidden or 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
104 changes: 104 additions & 0 deletions
104
graphdatascience/procedure_surface/api/config_endpoints.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from typing import Any | ||
|
|
||
|
|
||
| class ConfigEndpoints(ABC): | ||
| @property | ||
| @abstractmethod | ||
| def defaults(self) -> DefaultsEndpoints: | ||
| pass | ||
|
|
||
| @property | ||
| @abstractmethod | ||
| def limits(self) -> LimitsEndpoints: | ||
| pass | ||
|
|
||
|
|
||
| class DefaultsEndpoints(ABC): | ||
| @abstractmethod | ||
| def set( | ||
| self, | ||
| key: str, | ||
| value: Any, | ||
| username: str | None = None, | ||
| ) -> None: | ||
| """ | ||
| Configure a new default configuration value. | ||
|
|
||
| Parameters: | ||
| key : str | ||
| The configuration key for which the default value is being set. | ||
| value : Any | ||
| The value to set as the default for the given key. | ||
| username : str | None, default=None | ||
| If set, the configuration will be set for the given user. | ||
|
|
||
| Returns: None | ||
| """ | ||
| pass | ||
|
|
||
| @abstractmethod | ||
| def list( | ||
| self, | ||
| username: str | None = None, | ||
| key: str | None = None, | ||
| ) -> dict[str, Any]: | ||
| """ | ||
| List configured default configuration values. | ||
|
|
||
| Parameters: | ||
| key : str | None (default=None) | ||
| List only the default value for the given key. | ||
| username : str | None, default=None | ||
| List only default values for the given user. | ||
|
|
||
| Returns: dict[str, Any] | ||
| A dictionary containing the default configuration values. | ||
| """ | ||
| pass | ||
|
|
||
|
|
||
| class LimitsEndpoints(ABC): | ||
| @abstractmethod | ||
| def set( | ||
| self, | ||
| key: str, | ||
| value: Any, | ||
| username: str | None = None, | ||
| ) -> None: | ||
| """ | ||
| Configure a new limit for a configuration value. | ||
|
|
||
| Parameters: | ||
| key : str | ||
| The configuration key for which the limit is being set. | ||
| value : Any | ||
| The value to set as the limit for the given key. | ||
| username : str | None, default=None | ||
| If set, the limit will be set for the given user. | ||
|
|
||
| Returns: None | ||
| """ | ||
| pass | ||
|
|
||
| @abstractmethod | ||
| def list( | ||
| self, | ||
| username: str | None = None, | ||
| key: str | None = None, | ||
| ) -> dict[str, Any]: | ||
| """ | ||
| List configured configuration limits. | ||
|
|
||
| Parameters: | ||
| key : str | None (default=None) | ||
| List only the limits for the given key. | ||
| username : str | None, default=None | ||
| List only liomits for the given user. | ||
|
|
||
| Returns: dict[str, Any] | ||
| A dictionary containing the configuration limits. | ||
| """ | ||
| pass |
26 changes: 26 additions & 0 deletions
26
graphdatascience/procedure_surface/api/system_endpoints.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from abc import ABC, abstractmethod | ||
|
|
||
| from graphdatascience.procedure_surface.api.base_result import BaseResult | ||
|
|
||
|
|
||
| class SystemEndpoints(ABC): | ||
| @abstractmethod | ||
| def list_progress( | ||
| self, | ||
| job_id: str | None = None, | ||
| show_completed: bool = False, | ||
| ) -> list[ProgressResult]: | ||
| pass | ||
|
|
||
|
|
||
| class ProgressResult(BaseResult): | ||
| username: str | ||
| job_id: str | ||
| task_name: str | ||
| progress: str | ||
| progress_bar: str | ||
| status: str | ||
| time_started: str | ||
| elapsed_time: str |
This file contains hidden or 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
87 changes: 87 additions & 0 deletions
87
graphdatascience/procedure_surface/arrow/config_arrow_endpoints.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import Any | ||
|
|
||
| from graphdatascience.arrow_client.authenticated_flight_client import AuthenticatedArrowClient | ||
| from graphdatascience.arrow_client.v2.data_mapper_utils import deserialize | ||
| from graphdatascience.procedure_surface.api.config_endpoints import ( | ||
| ConfigEndpoints, | ||
| DefaultsEndpoints, | ||
| LimitsEndpoints, | ||
| ) | ||
| from graphdatascience.procedure_surface.utils.config_converter import ConfigConverter | ||
|
|
||
|
|
||
| class ConfigArrowEndpoints(ConfigEndpoints): | ||
| def __init__(self, arrow_client: AuthenticatedArrowClient): | ||
| self._arrow_client = arrow_client | ||
|
|
||
| @property | ||
| def defaults(self) -> DefaultsEndpoints: | ||
| return DefaultsArrowEndpoints(self._arrow_client) | ||
|
|
||
| @property | ||
| def limits(self) -> LimitsEndpoints: | ||
| return LimitsArrowEndpoints(self._arrow_client) | ||
|
|
||
|
|
||
| class DefaultsArrowEndpoints(DefaultsEndpoints): | ||
| def __init__(self, arrow_client: AuthenticatedArrowClient): | ||
| self._arrow_client = arrow_client | ||
|
|
||
| def set( | ||
| self, | ||
| key: str, | ||
| value: Any, | ||
| username: str | None = None, | ||
| ) -> None: | ||
| key = ConfigConverter.convert_to_camel_case(key) | ||
| deserialize(self._arrow_client.do_action_with_retry("v2/defaults.set", {key: value})) | ||
|
|
||
| def list( | ||
| self, | ||
| username: str | None = None, | ||
| key: str | None = None, | ||
| ) -> dict[str, Any]: | ||
| config = ConfigConverter.convert_to_gds_config( | ||
| key=key, | ||
| ) | ||
|
|
||
| rows = deserialize(self._arrow_client.do_action_with_retry("v2/defaults.list", config)) | ||
| result = {} | ||
|
|
||
| for row in rows: | ||
| result[row["key"]] = row["value"] | ||
|
|
||
| return result | ||
|
|
||
|
|
||
| class LimitsArrowEndpoints(LimitsEndpoints): | ||
| def __init__(self, arrow_client: AuthenticatedArrowClient): | ||
| self._arrow_client = arrow_client | ||
|
|
||
| def set( | ||
| self, | ||
| key: str, | ||
| value: Any, | ||
| username: str | None = None, | ||
| ) -> None: | ||
| key = ConfigConverter.convert_to_camel_case(key) | ||
| deserialize(self._arrow_client.do_action_with_retry("v2/limits.set", {key: value})) | ||
|
|
||
| def list( | ||
| self, | ||
| username: str | None = None, | ||
| key: str | None = None, | ||
| ) -> dict[str, Any]: | ||
| config = ConfigConverter.convert_to_gds_config( | ||
| key=key, | ||
| ) | ||
|
|
||
| rows = deserialize(self._arrow_client.do_action_with_retry("v2/limits.list", config)) | ||
| result = {} | ||
|
|
||
| for row in rows: | ||
| result[row["key"]] = row["value"] | ||
|
|
||
| return result |
24 changes: 24 additions & 0 deletions
24
graphdatascience/procedure_surface/arrow/system_arrow_endpoints.py
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from graphdatascience.arrow_client.authenticated_flight_client import AuthenticatedArrowClient | ||
| from graphdatascience.arrow_client.v2.data_mapper_utils import deserialize | ||
| from graphdatascience.procedure_surface.api.system_endpoints import ProgressResult, SystemEndpoints | ||
| from graphdatascience.procedure_surface.utils.config_converter import ConfigConverter | ||
|
|
||
|
|
||
| class SystemArrowEndpoints(SystemEndpoints): | ||
| def __init__(self, arrow_client: AuthenticatedArrowClient): | ||
| self._arrow_client = arrow_client | ||
|
|
||
| def list_progress( | ||
| self, | ||
| job_id: str | None = None, | ||
| show_completed: bool = False, | ||
| ) -> list[ProgressResult]: | ||
| config = ConfigConverter.convert_to_gds_config( | ||
| job_id=job_id, | ||
| show_completed=show_completed, | ||
| ) | ||
|
|
||
| rows = deserialize(self._arrow_client.do_action_with_retry("v2/listProgress", config)) | ||
| return [ProgressResult(**row) for row in rows] | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.