Skip to content

Commit 73d6a9b

Browse files
author
Andrei Neagu
committed
Merge remote-tracking branch 'upstream/master' into pr-osparc-add-not-long-running-rpc-interface-to-dy-sidecar
2 parents 556bdea + 6906f54 commit 73d6a9b

File tree

123 files changed

+1902
-923
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+1902
-923
lines changed

packages/aws-library/requirements/_base.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
aio-pika==9.5.5
22
# via -r requirements/../../../packages/service-library/requirements/_base.in
3-
aioboto3==14.1.0
3+
aioboto3==14.3.0
44
# via -r requirements/_base.in
5-
aiobotocore==2.21.1
5+
aiobotocore==2.22.0
66
# via aioboto3
77
aiocache==0.12.3
88
# via
@@ -57,9 +57,9 @@ attrs==25.1.0
5757
# aiohttp
5858
# jsonschema
5959
# referencing
60-
boto3==1.37.1
60+
boto3==1.37.3
6161
# via aiobotocore
62-
botocore==1.37.1
62+
botocore==1.37.3
6363
# via
6464
# aiobotocore
6565
# boto3

packages/aws-library/requirements/_test.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ aws-xray-sdk==2.14.0
2020
# via moto
2121
blinker==1.9.0
2222
# via flask
23-
boto3==1.37.1
23+
boto3==1.37.3
2424
# via
2525
# -c requirements/_base.txt
2626
# aws-sam-translator
2727
# moto
28-
botocore==1.37.1
28+
botocore==1.37.3
2929
# via
3030
# -c requirements/_base.txt
3131
# aws-xray-sdk

packages/models-library/src/models_library/api_schemas_directorv2/comp_runs.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from datetime import datetime
2-
from typing import Annotated, Any, NamedTuple
2+
from typing import Any, NamedTuple
33

4+
from models_library.services_types import ServiceRunID
45
from pydantic import (
6+
AnyUrl,
57
BaseModel,
6-
BeforeValidator,
78
ConfigDict,
89
PositiveInt,
910
)
@@ -62,20 +63,16 @@ class ComputationRunRpcGetPage(NamedTuple):
6263
total: PositiveInt
6364

6465

65-
def _none_to_zero_float_pre_validator(value: Any):
66-
if value is None:
67-
return 0.0
68-
return value
69-
70-
7166
class ComputationTaskRpcGet(BaseModel):
7267
project_uuid: ProjectID
7368
node_id: NodeID
7469
state: RunningState
75-
progress: Annotated[float, BeforeValidator(_none_to_zero_float_pre_validator)]
70+
progress: float
7671
image: dict[str, Any]
7772
started_at: datetime | None
7873
ended_at: datetime | None
74+
log_download_link: AnyUrl | None
75+
service_run_id: ServiceRunID
7976

8077
model_config = ConfigDict(
8178
json_schema_extra={
@@ -92,6 +89,8 @@ class ComputationTaskRpcGet(BaseModel):
9289
},
9390
"started_at": "2023-01-11 13:11:47.293595",
9491
"ended_at": "2023-01-11 13:11:47.293595",
92+
"log_download_link": "https://example.com/logs",
93+
"service_run_id": "comp_1_12e0c8b2-bad6-40fb-9948-8dec4f65d4d9_1",
9594
}
9695
]
9796
}

packages/models-library/src/models_library/api_schemas_webserver/computations.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from datetime import datetime
2+
from decimal import Decimal
23
from typing import Annotated, Any
34

45
from common_library.basic_types import DEFAULT_FACTORY
56
from pydantic import (
7+
AnyUrl,
68
BaseModel,
79
ConfigDict,
810
Field,
@@ -79,7 +81,11 @@ class ComputationStarted(OutputSchemaWithoutCamelCase):
7981
class ComputationRunListQueryParams(
8082
PageQueryParameters,
8183
ComputationRunListOrderParams, # type: ignore[misc, valid-type]
82-
): ...
84+
):
85+
filter_only_running: bool = Field(
86+
default=False,
87+
description="If true, only running computations are returned",
88+
)
8389

8490

8591
class ComputationRunRestGet(OutputSchema):
@@ -90,6 +96,8 @@ class ComputationRunRestGet(OutputSchema):
9096
submitted_at: datetime
9197
started_at: datetime | None
9298
ended_at: datetime | None
99+
root_project_name: str
100+
project_custom_metadata: dict[str, Any]
93101

94102

95103
### Computation Task
@@ -123,3 +131,6 @@ class ComputationTaskRestGet(OutputSchema):
123131
image: dict[str, Any]
124132
started_at: datetime | None
125133
ended_at: datetime | None
134+
log_download_link: AnyUrl | None
135+
node_name: str
136+
osparc_credits: Decimal | None
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
from datetime import datetime
2+
from decimal import Decimal
3+
from typing import Any
4+
5+
from pydantic import AnyUrl, BaseModel
6+
7+
from .projects import ProjectID
8+
from .projects_nodes_io import NodeID
9+
from .projects_state import RunningState
10+
11+
12+
class ComputationTaskWithAttributes(BaseModel):
13+
project_uuid: ProjectID
14+
node_id: NodeID
15+
state: RunningState
16+
progress: float
17+
image: dict[str, Any]
18+
started_at: datetime | None
19+
ended_at: datetime | None
20+
log_download_link: AnyUrl | None
21+
22+
# Attributes added by the webserver
23+
node_name: str
24+
osparc_credits: Decimal | None
25+
26+
27+
class ComputationRunWithAttributes(BaseModel):
28+
project_uuid: ProjectID
29+
iteration: int
30+
state: RunningState
31+
info: dict[str, Any]
32+
submitted_at: datetime
33+
started_at: datetime | None
34+
ended_at: datetime | None
35+
36+
# Attributes added by the webserver
37+
root_project_name: str
38+
project_custom_metadata: dict[str, Any]

packages/models-library/src/models_library/projects_state.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ class RunningState(str, Enum):
3535
ABORTED = "ABORTED"
3636
WAITING_FOR_CLUSTER = "WAITING_FOR_CLUSTER"
3737

38-
def is_running(self) -> bool:
39-
return self in (
38+
@staticmethod
39+
def list_running_states() -> list["RunningState"]:
40+
return [
4041
RunningState.PUBLISHED,
4142
RunningState.PENDING,
4243
RunningState.WAITING_FOR_RESOURCES,
4344
RunningState.STARTED,
4445
RunningState.WAITING_FOR_CLUSTER,
45-
)
46+
]
47+
48+
def is_running(self) -> bool:
49+
return self in self.list_running_states()
4650

4751

4852
@unique

packages/pytest-simcore/src/pytest_simcore/aws_s3_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def s3_client(s3_settings: S3Settings) -> typing.AsyncIterator[S3Client]:
2525
exit_stack = contextlib.AsyncExitStack()
2626
session_client = session.client(
2727
"s3",
28-
endpoint_url=f"{s3_settings.S3_ENDPOINT}",
28+
endpoint_url=f"{s3_settings.S3_ENDPOINT}" if s3_settings.S3_ENDPOINT else None,
2929
aws_access_key_id=s3_settings.S3_ACCESS_KEY,
3030
aws_secret_access_key=s3_settings.S3_SECRET_KEY,
3131
region_name=s3_settings.S3_REGION,

packages/service-library/src/servicelib/aiohttp/long_running_tasks/server.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
The server only has to return a `TaskId` in the handler creating the long
66
running task.
77
"""
8+
89
from ...long_running_tasks._errors import TaskAlreadyRunningError, TaskCancelledError
910
from ...long_running_tasks._models import ProgressMessage, ProgressPercent
1011
from ...long_running_tasks._task import (
@@ -14,12 +15,17 @@
1415
TasksManager,
1516
TaskStatus,
1617
)
17-
from ._dependencies import create_task_name_from_request, get_tasks_manager
18+
from ._dependencies import (
19+
create_task_name_from_request,
20+
get_task_context,
21+
get_tasks_manager,
22+
)
1823
from ._routes import TaskGet
1924
from ._server import setup, start_long_running_task
2025

2126
__all__: tuple[str, ...] = (
2227
"create_task_name_from_request",
28+
"get_task_context",
2329
"get_tasks_manager",
2430
"ProgressMessage",
2531
"ProgressPercent",

packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/director_v2/computations.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ async def list_computations_latest_iteration_page(
3333
*,
3434
product_name: ProductName,
3535
user_id: UserID,
36+
# filters
37+
filter_only_running: bool = False,
3638
# pagination
3739
offset: int = 0,
3840
limit: int = 20,
@@ -46,6 +48,7 @@ async def list_computations_latest_iteration_page(
4648
),
4749
product_name=product_name,
4850
user_id=user_id,
51+
filter_only_running=filter_only_running,
4952
offset=offset,
5053
limit=limit,
5154
order_by=order_by,

packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/resource_usage_tracker/credit_transactions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from decimal import Decimal
23
from typing import Final
34

45
from models_library.api_schemas_resource_usage_tracker import (
@@ -12,6 +13,7 @@
1213
from models_library.projects import ProjectID
1314
from models_library.rabbitmq_basic_types import RPCMethodName
1415
from models_library.resource_tracker import CreditTransactionStatus
16+
from models_library.services_types import ServiceRunID
1517
from models_library.wallets import WalletID
1618
from pydantic import NonNegativeInt, TypeAdapter
1719

@@ -82,3 +84,21 @@ async def pay_project_debt(
8284
new_wallet_transaction=new_wallet_transaction,
8385
timeout_s=_DEFAULT_TIMEOUT_S,
8486
)
87+
88+
89+
@log_decorator(_logger, level=logging.DEBUG)
90+
async def get_transaction_current_credits_by_service_run_id(
91+
rabbitmq_rpc_client: RabbitMQRPCClient,
92+
*,
93+
service_run_id: ServiceRunID,
94+
) -> Decimal:
95+
result = await rabbitmq_rpc_client.request(
96+
RESOURCE_USAGE_TRACKER_RPC_NAMESPACE,
97+
_RPC_METHOD_NAME_ADAPTER.validate_python(
98+
"get_transaction_current_credits_by_service_run_id"
99+
),
100+
service_run_id=service_run_id,
101+
timeout_s=_DEFAULT_TIMEOUT_S,
102+
)
103+
assert isinstance(result, Decimal) # nosec
104+
return result

0 commit comments

Comments
 (0)