-
Notifications
You must be signed in to change notification settings - Fork 32
✨ task manager web-api listing (🗃️) #7544
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
sanderegg
merged 28 commits into
ITISFoundation:master
from
matusdrobuliak66:add-listing-of-comp-runs
Apr 22, 2025
Merged
Changes from 14 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
dc77030
intro
matusdrobuliak66 d47f6a6
revert
matusdrobuliak66 756b22a
fix test in director-v2
matusdrobuliak66 8b51296
fix
matusdrobuliak66 b13813c
fix
matusdrobuliak66 d7ece07
adding tests:
matusdrobuliak66 f82840e
Merge branch 'master' into add-listing-of-comp-runs
matusdrobuliak66 5eea03a
adding tests
matusdrobuliak66 840462a
adding tests to webserver
matusdrobuliak66 b2dc367
Merge branch 'master' into add-listing-of-comp-runs
matusdrobuliak66 b739492
remove comment
matusdrobuliak66 ee472d8
small cleanup
matusdrobuliak66 72f289e
add db indexes
matusdrobuliak66 243c5dc
fix
matusdrobuliak66 fb2a8d1
update open api specs
matusdrobuliak66 d786c64
review @pcrespov
matusdrobuliak66 f552f42
fix
matusdrobuliak66 93bb5ef
Merge branch 'master' into add-listing-of-comp-runs
matusdrobuliak66 cddeda5
Merge branch 'master' into add-listing-of-comp-runs
matusdrobuliak66 9e58ce3
review @sanderegg
matusdrobuliak66 d9ce804
Merge branch 'master' into add-listing-of-comp-runs
matusdrobuliak66 871f262
update open api specs
matusdrobuliak66 8db4e63
update open api specs
matusdrobuliak66 0ddce71
Merge branch 'master' into add-listing-of-comp-runs
matusdrobuliak66 cfc7164
Merge branch 'master' into add-listing-of-comp-runs
matusdrobuliak66 9bc685a
fix ordering of tasks
sanderegg 97b0f7e
Merge branch 'master' into add-listing-of-comp-runs
matusdrobuliak66 05789b5
Merge branch 'master' into add-listing-of-comp-runs
odeimaiz 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
11 changes: 11 additions & 0 deletions
11
packages/models-library/src/models_library/api_schemas_directorv2/__init__.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
103 changes: 103 additions & 0 deletions
103
packages/models-library/src/models_library/api_schemas_directorv2/comp_runs.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,103 @@ | ||
| from datetime import datetime | ||
| from typing import Annotated, Any, NamedTuple | ||
|
|
||
| from pydantic import ( | ||
| BaseModel, | ||
| BeforeValidator, | ||
| ConfigDict, | ||
| PositiveInt, | ||
| ) | ||
|
|
||
| from ..projects import ProjectID | ||
| from ..projects_nodes_io import NodeID | ||
| from ..projects_state import RunningState | ||
|
|
||
|
|
||
| class ComputationRunRpcGet(BaseModel): | ||
| project_uuid: ProjectID | ||
| iteration: int | ||
| state: RunningState | ||
| info: dict[str, Any] | ||
| submitted_at: datetime | ||
| started_at: datetime | None | ||
| ended_at: datetime | None | ||
|
|
||
| model_config = ConfigDict( | ||
| json_schema_extra={ | ||
| "examples": [ | ||
| { | ||
| "project_uuid": "beb16d18-d57d-44aa-a638-9727fa4a72ef", | ||
| "iteration": 1, | ||
| "state": "SUCCESS", | ||
| "info": { | ||
| "wallet_id": 9866, | ||
| "user_email": "[email protected]", | ||
| "wallet_name": "test", | ||
| "product_name": "osparc", | ||
| "project_name": "test", | ||
| "project_metadata": { | ||
| "parent_node_id": "12e0c8b2-bad6-40fb-9948-8dec4f65d4d9", | ||
| "parent_node_name": "UJyfwFVYySnPCaLuQIaz", | ||
| "parent_project_id": "beb16d18-d57d-44aa-a638-9727fa4a72ef", | ||
| "parent_project_name": "qTjDmYPxeqAWfCKCQCYF", | ||
| "root_parent_node_id": "37176e84-d977-4993-bc49-d76fcfc6e625", | ||
| "root_parent_node_name": "UEXExIZVPeFzGRmMglPr", | ||
| "root_parent_project_id": "beb16d18-d57d-44aa-a638-9727fa4a72ef", | ||
| "root_parent_project_name": "FuDpjjFIyeNTWRUWCuKo", | ||
| }, | ||
| "node_id_names_map": {}, | ||
| "simcore_user_agent": "agent", | ||
| }, | ||
| "submitted_at": "2023-01-11 13:11:47.293595", | ||
| "started_at": "2023-01-11 13:11:47.293595", | ||
| "ended_at": "2023-01-11 13:11:47.293595", | ||
| } | ||
| ] | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| class ComputationRunRpcGetPage(NamedTuple): | ||
| items: list[ComputationRunRpcGet] | ||
| total: PositiveInt | ||
|
|
||
|
|
||
| def _none_to_zero_float_pre_validator(value: Any): | ||
| if value is None: | ||
| return 0.0 | ||
| return value | ||
|
|
||
|
|
||
| class ComputationTaskRpcGet(BaseModel): | ||
| project_uuid: ProjectID | ||
| node_id: NodeID | ||
| state: RunningState | ||
| progress: Annotated[float, BeforeValidator(_none_to_zero_float_pre_validator)] | ||
| image: dict[str, Any] | ||
| started_at: datetime | None | ||
| ended_at: datetime | None | ||
|
|
||
| model_config = ConfigDict( | ||
| json_schema_extra={ | ||
| "examples": [ | ||
| { | ||
| "project_uuid": "beb16d18-d57d-44aa-a638-9727fa4a72ef", | ||
| "node_id": "12e0c8b2-bad6-40fb-9948-8dec4f65d4d9", | ||
| "state": "SUCCESS", | ||
| "progress": 0.0, | ||
| "image": { | ||
| "name": "simcore/services/comp/ti-solutions-optimizer", | ||
| "tag": "1.0.19", | ||
| "node_requirements": {"CPU": 8.0, "RAM": 25769803776}, | ||
| }, | ||
| "started_at": "2023-01-11 13:11:47.293595", | ||
| "ended_at": "2023-01-11 13:11:47.293595", | ||
| } | ||
| ] | ||
| } | ||
| ) | ||
|
|
||
|
|
||
| class ComputationTaskRpcGetPage(NamedTuple): | ||
| items: list[ComputationTaskRpcGet] | ||
| total: PositiveInt |
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
53 changes: 53 additions & 0 deletions
53
...c/simcore_postgres_database/migration/versions/f65f7786cd4b_add_indexes_to_comp_tables.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,53 @@ | ||
| """add indexes to comp tables | ||
|
|
||
| Revision ID: f65f7786cd4b | ||
| Revises: cf8f743fd0b7 | ||
| Create Date: 2025-04-17 12:44:27.577984+00:00 | ||
|
|
||
| """ | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "f65f7786cd4b" | ||
| down_revision = "cf8f743fd0b7" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.create_index("ix_comp_runs_user_id", "comp_runs", ["user_id"], unique=False) | ||
| op.create_index( | ||
| "ix_comp_tasks_project_id", "comp_tasks", ["project_id"], unique=False | ||
| ) | ||
| op.drop_index("idx_projects_last_change_date_desc", table_name="projects") | ||
| op.create_index( | ||
| "idx_projects_last_change_date_desc", | ||
| "projects", | ||
| ["last_change_date"], | ||
| unique=False, | ||
| postgresql_using="btree", | ||
| postgresql_ops={"last_change_date": "DESC"}, | ||
| ) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_index( | ||
| "idx_projects_last_change_date_desc", | ||
| table_name="projects", | ||
| postgresql_using="btree", | ||
| postgresql_ops={"last_change_date": "DESC"}, | ||
| ) | ||
| op.create_index( | ||
| "idx_projects_last_change_date_desc", | ||
| "projects", | ||
| [sa.text("last_change_date DESC")], | ||
| unique=False, | ||
| ) | ||
| op.drop_index("ix_comp_tasks_project_id", table_name="comp_tasks") | ||
| op.drop_index("ix_comp_runs_user_id", table_name="comp_runs") | ||
| # ### end Alembic commands ### |
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
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
Empty file.
85 changes: 85 additions & 0 deletions
85
packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/director_v2/computations.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,85 @@ | ||
| # pylint: disable=too-many-arguments | ||
| import logging | ||
| from typing import Final | ||
|
|
||
| from models_library.api_schemas_directorv2 import ( | ||
| DIRECTOR_V2_RPC_NAMESPACE, | ||
| ) | ||
| from models_library.api_schemas_directorv2.comp_runs import ( | ||
| ComputationRunRpcGetPage, | ||
| ComputationTaskRpcGetPage, | ||
| ) | ||
| from models_library.products import ProductName | ||
| from models_library.projects import ProjectID | ||
| from models_library.rabbitmq_basic_types import RPCMethodName | ||
| from models_library.rest_ordering import OrderBy | ||
| from models_library.users import UserID | ||
| from pydantic import NonNegativeInt, TypeAdapter | ||
|
|
||
| from ....logging_utils import log_decorator | ||
| from ... import RabbitMQRPCClient | ||
|
|
||
| _logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| _DEFAULT_TIMEOUT_S: Final[NonNegativeInt] = 20 | ||
|
|
||
| _RPC_METHOD_NAME_ADAPTER: TypeAdapter[RPCMethodName] = TypeAdapter(RPCMethodName) | ||
|
|
||
|
|
||
| @log_decorator(_logger, level=logging.DEBUG) | ||
| async def list_computations_latest_iteration_page( | ||
| rabbitmq_rpc_client: RabbitMQRPCClient, | ||
| *, | ||
| product_name: ProductName, | ||
| user_id: UserID, | ||
| # pagination | ||
| offset: int = 0, | ||
| limit: int = 20, | ||
| # ordering | ||
| order_by: OrderBy | None = None, | ||
| ) -> ComputationRunRpcGetPage: | ||
| result = await rabbitmq_rpc_client.request( | ||
| DIRECTOR_V2_RPC_NAMESPACE, | ||
| _RPC_METHOD_NAME_ADAPTER.validate_python( | ||
| "list_computations_latest_iteration_page" | ||
| ), | ||
| product_name=product_name, | ||
| user_id=user_id, | ||
| offset=offset, | ||
| limit=limit, | ||
| order_by=order_by, | ||
| timeout_s=_DEFAULT_TIMEOUT_S, | ||
| ) | ||
| assert isinstance(result, ComputationRunRpcGetPage) # nosec | ||
| return result | ||
|
|
||
|
|
||
| @log_decorator(_logger, level=logging.DEBUG) | ||
| async def list_computations_latest_iteration_tasks_page( | ||
| rabbitmq_rpc_client: RabbitMQRPCClient, | ||
| *, | ||
| product_name: ProductName, | ||
| user_id: UserID, | ||
| project_id: ProjectID, | ||
| # pagination | ||
| offset: int = 0, | ||
| limit: int = 20, | ||
| # ordering | ||
| order_by: OrderBy | None = None, | ||
| ) -> ComputationTaskRpcGetPage: | ||
| result = await rabbitmq_rpc_client.request( | ||
| DIRECTOR_V2_RPC_NAMESPACE, | ||
| _RPC_METHOD_NAME_ADAPTER.validate_python( | ||
| "list_computations_latest_iteration_tasks_page" | ||
| ), | ||
| product_name=product_name, | ||
| user_id=user_id, | ||
| project_id=project_id, | ||
| offset=offset, | ||
| limit=limit, | ||
| order_by=order_by, | ||
| timeout_s=_DEFAULT_TIMEOUT_S, | ||
| ) | ||
| assert isinstance(result, ComputationTaskRpcGetPage) # nosec | ||
| return result |
Oops, something went wrong.
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.