From c4ba87e653ef9fcc4e754fcb70d278941df7f514 Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Wed, 1 Oct 2025 18:19:53 +0200 Subject: [PATCH 01/13] feat(booking): wip booking --- Makefile | 5 +- openapi/scaleway.qaas.v1alpha1.Api.yml | 19 +++ scaleway_qaas_client/v1alpha1/__init__.py | 6 + scaleway_qaas_client/v1alpha1/client.py | 113 ++++++++++++++++++ ...v1_alpha_1_platform_booking_requirement.py | 41 +++++++ tests/test_api.py | 4 + 6 files changed, 187 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d5006c1..8dbc619 100644 --- a/Makefile +++ b/Makefile @@ -40,4 +40,7 @@ install-test: .PHONY: test test: - pytest -s --showprogress -vv tests/ \ No newline at end of file + pytest -s --showprogress -vv tests/ + +.PHONY: all +all: v1alpha1 \ No newline at end of file diff --git a/openapi/scaleway.qaas.v1alpha1.Api.yml b/openapi/scaleway.qaas.v1alpha1.Api.yml index 33f9894..c6e8e67 100644 --- a/openapi/scaleway.qaas.v1alpha1.Api.yml +++ b/openapi/scaleway.qaas.v1alpha1.Api.yml @@ -863,11 +863,30 @@ components: can be booked in the future. (in seconds) example: 2.5s nullable: true + min_planification_duration: + type: string + description: Minimum planification time before a platform can be booked. + (in seconds) + example: 2.5s + nullable: true + max_booking_per_week: + type: integer + description: Maximum amount of booking allowed for one organization + per week. + format: uint32 + max_booking_per_day: + type: integer + description: Maximum amount of booking allowed for one organization + per day. + format: uint32 x-properties-order: - min_duration - max_duration - max_cancellation_duration - max_planification_duration + - min_planification_duration + - max_booking_per_week + - max_booking_per_day description: type: string description: English description of the platform. diff --git a/scaleway_qaas_client/v1alpha1/__init__.py b/scaleway_qaas_client/v1alpha1/__init__.py index 07829c4..014930e 100644 --- a/scaleway_qaas_client/v1alpha1/__init__.py +++ b/scaleway_qaas_client/v1alpha1/__init__.py @@ -65,3 +65,9 @@ from .quantum_as_a_service_api_client.models import ( ScalewayQaasV1Alpha1SessionStatus as QaaSSessionStatus, ) +from quantum_as_a_service_api_client.models import ( + ScalewayQaasV1Alpha1PlatformBookingRequirement as QaaSBookingRequirements, +) +from quantum_as_a_service_api_client.models import ( + ScalewayQaasV1Alpha1Booking as QaaSBooking, +) diff --git a/scaleway_qaas_client/v1alpha1/client.py b/scaleway_qaas_client/v1alpha1/client.py index b8ecf12..c41b82d 100644 --- a/scaleway_qaas_client/v1alpha1/client.py +++ b/scaleway_qaas_client/v1alpha1/client.py @@ -89,6 +89,12 @@ from scaleway_qaas_client.v1alpha1.quantum_as_a_service_api_client.api.sessions.terminate_session import ( sync_detailed as _terminate_session_sync, ) +from scaleway_qaas_client.v1alpha1.quantum_as_a_service_api_client.api.bookings.get_booking import ( + sync_detailed as _get_booking_sync, +) +from scaleway_qaas_client.v1alpha1.quantum_as_a_service_api_client.api.bookings.list_bookings import ( + sync_detailed as _list_bookings_sync, +) from scaleway_qaas_client.v1alpha1.quantum_as_a_service_api_client.client import ( AuthenticatedClient, ) @@ -100,12 +106,14 @@ CreateModelBody, CreateProcessBody, CreateSessionBody, + CreateSessionBodyBookingDemand, ListPlatformsPlatformTechnology, ListPlatformsPlatformType, ScalewayQaasV1Alpha1Application, ScalewayQaasV1Alpha1Job, ScalewayQaasV1Alpha1JobResult, ScalewayQaasV1Alpha1Model, + ScalewayQaasV1Alpha1Booking, ScalewayQaasV1Alpha1Platform, ScalewayQaasV1Alpha1Process, ScalewayQaasV1Alpha1ProcessResult, @@ -239,6 +247,9 @@ def create_session( name: Optional[str] = None, model_id: Optional[str] = None, parameters: Optional[Union[Dict, List, str]] = None, + booking_demand_started_at: Optional[str] = None, + booking_demand_finished_at: Optional[str] = None, + booking_demand_description: Optional[str] = None, ) -> ScalewayQaasV1Alpha1Session: """Create a session @@ -261,6 +272,16 @@ def create_session( ScalewayQaasV1Alpha1Session """ + if not booking_demand_started_at and booking_demand_finished_at: + raise Exception( + "booking_demand_started_at and booking_demand_finished_at must be set" + ) + + if booking_demand_started_at and not booking_demand_finished_at: + raise Exception( + "booking_demand_started_at and booking_demand_finished_at must be set" + ) + if not platform_id: raise Exception("create_session: platform_id cannot be None") @@ -277,6 +298,15 @@ def create_session( if isinstance(max_idle_duration, str): max_idle_duration = f"{timeparse(max_idle_duration)}s" + booking_demand = UNSET + + if booking_demand_started_at and booking_demand_finished_at: + booking_demand = CreateSessionBodyBookingDemand( + started_at=booking_demand_started_at, + finished_at=booking_demand_finished_at, + description=booking_demand_description, + ) + response = _create_session_sync( client=self.__client, body=CreateSessionBody( @@ -288,6 +318,7 @@ def create_session( max_idle_duration=max_idle_duration, model_id=model_id, parameters=parameters, + booking_demand=booking_demand, ), ) @@ -890,3 +921,85 @@ def list_models(self) -> List[ScalewayQaasV1Alpha1Model]: _raise_on_error(response) return response.parsed.models + + def get_booking(self, booking_id: str) -> ScalewayQaasV1Alpha1Booking: + """Get booking information + + Retrieve information about the provided **booking ID**, such as description, status and progress + message. + + Args: + booking_id (str): Unique ID of the booking. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ScalewayQaasV1Alpha1Booking] + """ + + if not booking_id: + raise Exception("get_booking: booking_id cannot be None") + + response = _get_booking_sync(client=self.__client, booking_id=booking_id) + + _raise_on_error(response) + + return response.parsed + + def list_platform_bookings( + self, platform_id: str + ) -> List[ScalewayQaasV1Alpha1Booking]: + """List all bookings according of the target platform + + Retrieve information about all bookings of the provided ** platform ID**. + + Args: + platform_id (Union[Unset, str]): List bookings attached to this platform ID. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ScalewayQaasV1Alpha1ListBookingsResponse] + """ + + response = _list_bookings_sync(client=self.__client, platform_id=platform_id) + + _raise_on_error(response) + + return response.parsed.bookings + + def list_bookings( + self, platform_id: Optional[str] = None + ) -> List[ScalewayQaasV1Alpha1Booking]: + """List all bookings according the filter of the current project. + + Retrieve information about all bookings of the project ID. + + Args: + platform_id (Union[Unset, str]): Will list only bookings attached to this platform ID. + + Raises: + errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. + httpx.TimeoutException: If the request takes longer than Client.timeout. + + Returns: + Response[ScalewayQaasV1Alpha1ListBookingsResponse] + """ + if platform_id: + response = _list_bookings_sync( + client=self.__client, + platform_id=platform_id, + project_id=self.__project_id, + ) + else: + response = _list_bookings_sync( + client=self.__client, project_id=self.__project_id + ) + + _raise_on_error(response) + + return response.parsed.bookings diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/scaleway_qaas_v1_alpha_1_platform_booking_requirement.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/scaleway_qaas_v1_alpha_1_platform_booking_requirement.py index c38d639..625033e 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/scaleway_qaas_v1_alpha_1_platform_booking_requirement.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/scaleway_qaas_v1_alpha_1_platform_booking_requirement.py @@ -22,12 +22,19 @@ class ScalewayQaasV1Alpha1PlatformBookingRequirement: before the beginning of the session. (in seconds) Example: 2.5s. max_planification_duration (Union[None, Unset, str]): Allowed planification time from now where the platform can be booked in the future. (in seconds) Example: 2.5s. + min_planification_duration (Union[None, Unset, str]): Minimum planification time before a platform can be + booked. (in seconds) Example: 2.5s. + max_booking_per_week (Union[Unset, int]): Maximum amount of booking allowed for one organization per week. + max_booking_per_day (Union[Unset, int]): Maximum amount of booking allowed for one organization per day. """ min_duration: Union[None, Unset, str] = UNSET max_duration: Union[None, Unset, str] = UNSET max_cancellation_duration: Union[None, Unset, str] = UNSET max_planification_duration: Union[None, Unset, str] = UNSET + min_planification_duration: Union[None, Unset, str] = UNSET + max_booking_per_week: Union[Unset, int] = UNSET + max_booking_per_day: Union[Unset, int] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -55,6 +62,16 @@ def to_dict(self) -> dict[str, Any]: else: max_planification_duration = self.max_planification_duration + min_planification_duration: Union[None, Unset, str] + if isinstance(self.min_planification_duration, Unset): + min_planification_duration = UNSET + else: + min_planification_duration = self.min_planification_duration + + max_booking_per_week = self.max_booking_per_week + + max_booking_per_day = self.max_booking_per_day + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) @@ -66,6 +83,12 @@ def to_dict(self) -> dict[str, Any]: field_dict["max_cancellation_duration"] = max_cancellation_duration if max_planification_duration is not UNSET: field_dict["max_planification_duration"] = max_planification_duration + if min_planification_duration is not UNSET: + field_dict["min_planification_duration"] = min_planification_duration + if max_booking_per_week is not UNSET: + field_dict["max_booking_per_week"] = max_booking_per_week + if max_booking_per_day is not UNSET: + field_dict["max_booking_per_day"] = max_booking_per_day return field_dict @@ -113,11 +136,29 @@ def _parse_max_planification_duration(data: object) -> Union[None, Unset, str]: d.pop("max_planification_duration", UNSET) ) + def _parse_min_planification_duration(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + min_planification_duration = _parse_min_planification_duration( + d.pop("min_planification_duration", UNSET) + ) + + max_booking_per_week = d.pop("max_booking_per_week", UNSET) + + max_booking_per_day = d.pop("max_booking_per_day", UNSET) + scaleway_qaas_v1_alpha_1_platform_booking_requirement = cls( min_duration=min_duration, max_duration=max_duration, max_cancellation_duration=max_cancellation_duration, max_planification_duration=max_planification_duration, + min_planification_duration=min_planification_duration, + max_booking_per_week=max_booking_per_week, + max_booking_per_day=max_booking_per_day, ) scaleway_qaas_v1_alpha_1_platform_booking_requirement.additional_properties = d diff --git a/tests/test_api.py b/tests/test_api.py index 4c4e73a..15f8e70 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -152,6 +152,10 @@ def test_create_delete_session(): client.delete_session(session.id) +def test_platform_bookings(): + client = _get_client() + + def test_create_session_same_deduplication_id(): client = _get_client() From b389fbb787186eabd30085c88ef24a23794d5f2a Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Wed, 1 Oct 2025 18:28:58 +0200 Subject: [PATCH 02/13] feat(booking): wip booking --- scaleway_qaas_client/v1alpha1/__init__.py | 4 ++-- scaleway_qaas_client/v1alpha1/client.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scaleway_qaas_client/v1alpha1/__init__.py b/scaleway_qaas_client/v1alpha1/__init__.py index 014930e..0bd96f5 100644 --- a/scaleway_qaas_client/v1alpha1/__init__.py +++ b/scaleway_qaas_client/v1alpha1/__init__.py @@ -65,9 +65,9 @@ from .quantum_as_a_service_api_client.models import ( ScalewayQaasV1Alpha1SessionStatus as QaaSSessionStatus, ) -from quantum_as_a_service_api_client.models import ( +from .quantum_as_a_service_api_client.models import ( ScalewayQaasV1Alpha1PlatformBookingRequirement as QaaSBookingRequirements, ) -from quantum_as_a_service_api_client.models import ( +from .quantum_as_a_service_api_client.models import ( ScalewayQaasV1Alpha1Booking as QaaSBooking, ) diff --git a/scaleway_qaas_client/v1alpha1/client.py b/scaleway_qaas_client/v1alpha1/client.py index c41b82d..bb84b35 100644 --- a/scaleway_qaas_client/v1alpha1/client.py +++ b/scaleway_qaas_client/v1alpha1/client.py @@ -16,6 +16,7 @@ import randomname from pytimeparse.timeparse import timeparse +from datetime import datetime from scaleway_qaas_client.v1alpha1.quantum_as_a_service_api_client.api.applications.get_application import ( sync_detailed as _get_application_sync, @@ -247,8 +248,8 @@ def create_session( name: Optional[str] = None, model_id: Optional[str] = None, parameters: Optional[Union[Dict, List, str]] = None, - booking_demand_started_at: Optional[str] = None, - booking_demand_finished_at: Optional[str] = None, + booking_demand_started_at: Optional[datetime] = None, + booking_demand_finished_at: Optional[datetime] = None, booking_demand_description: Optional[str] = None, ) -> ScalewayQaasV1Alpha1Session: """Create a session @@ -263,6 +264,9 @@ def create_session( max_duration (Union[None, Unset, str]): Maximum duration before the session ends. (in seconds) Example: 20m. deduplication_id (Union[None, Unset, str]): Deduplication ID of the session. model_id (Union[None, Unset, str]): Default computation model ID to be executed by job assigned to this session. + booking_demand_started_at (Union[None, Unset, datetime.datetime]): Wished started time for an exclusive session over a QPU, only works if the platform is_bookable (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z. + booking_demand_finished_at (Union[None, Unset, datetime.datetime]): Wished finished time for an exclusive session over a QPU, only works if the platform is_bookable (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z. + booking_demand_description (Union[None, Unset, str]): User description of the booking Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. From 3eedce886abfbd3c5d7cb354724c34e301c5b2c8 Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Thu, 9 Oct 2025 18:42:43 +0200 Subject: [PATCH 03/13] feat(booking): log quandela booking --- .gitignore | 2 + scaleway_qaas_client/v1alpha1/client.py | 21 +++- tests/test_api.py | 130 +++++++++++++----------- 3 files changed, 88 insertions(+), 65 deletions(-) diff --git a/.gitignore b/.gitignore index b7faf40..41793b4 100644 --- a/.gitignore +++ b/.gitignore @@ -205,3 +205,5 @@ cython_debug/ marimo/_static/ marimo/_lsp/ __marimo__/ + +*.env \ No newline at end of file diff --git a/scaleway_qaas_client/v1alpha1/client.py b/scaleway_qaas_client/v1alpha1/client.py index bb84b35..cb9d700 100644 --- a/scaleway_qaas_client/v1alpha1/client.py +++ b/scaleway_qaas_client/v1alpha1/client.py @@ -305,9 +305,14 @@ def create_session( booking_demand = UNSET if booking_demand_started_at and booking_demand_finished_at: + booking_demand_started_at_timestamp = booking_demand_started_at.timestamp() + booking_demand_finished_at_timestamp = booking_demand_finished_at.timestamp() + # seconds = int(booking_demand_started_at_timestamp) + # nanos = int(booking_demand_started_at_timestamp % 1 * 1e9) + booking_demand = CreateSessionBodyBookingDemand( - started_at=booking_demand_started_at, - finished_at=booking_demand_finished_at, + started_at=booking_demand_started_at_timestamp, + finished_at=booking_demand_finished_at_timestamp, description=booking_demand_description, ) @@ -955,7 +960,7 @@ def get_booking(self, booking_id: str) -> ScalewayQaasV1Alpha1Booking: def list_platform_bookings( self, platform_id: str ) -> List[ScalewayQaasV1Alpha1Booking]: - """List all bookings according of the target platform + """List all bookings of the target platform Retrieve information about all bookings of the provided ** platform ID**. @@ -979,9 +984,9 @@ def list_platform_bookings( def list_bookings( self, platform_id: Optional[str] = None ) -> List[ScalewayQaasV1Alpha1Booking]: - """List all bookings according the filter of the current project. + """List all bookings according of the current project - Retrieve information about all bookings of the project ID. + Retrieve information about all bookings of the project ID, can be filtered by platform ID. Args: platform_id (Union[Unset, str]): Will list only bookings attached to this platform ID. @@ -1007,3 +1012,9 @@ def list_bookings( _raise_on_error(response) return response.parsed.bookings + + +# def _datetime_to_timestamp(time : datetime) -> Tuple[int, int]: +# timestamp = time.timestamp() +# seconds = int(timestamp) +# nanos = int(booking_demand_started_at_timestamp % 1 * 1e9) \ No newline at end of file diff --git a/tests/test_api.py b/tests/test_api.py index 15f8e70..3b69b35 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -15,6 +15,7 @@ import time import uuid +from datetime import datetime, timedelta, timezone from scaleway_qaas_client.v1alpha1 import QaaSClient _RANDOM_UUID = str(uuid.uuid4()) @@ -128,6 +129,9 @@ def test_create_delete_session(): max_idle_duration=max_idle_duration, ) + print(session.updated_at) + print(session.created_at) + assert session is not None assert session.id is not None assert session.platform_id == target_platform.id @@ -152,9 +156,74 @@ def test_create_delete_session(): client.delete_session(session.id) -def test_platform_bookings(): +def test_list_platform_bookings(): client = _get_client() + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert platforms is not None + assert len(platforms) == 1 + + target_platform = platforms[0] + + assert target_platform.id is not None + + bookings = client.list_platform_bookings(target_platform.id) + + assert len(bookings) > 0 + +def test_create_and_cancel_booking(): + client = _get_client() + + try: + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(days=7) + booking_finish = booking_start + timedelta(hours=1) + booking_description = "my lovely booking" + + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description + ) + + assert session is not None + assert session.id is not None + assert session.platform_id == target_platform.id + assert session.booking_id is not None + + booking = client.get_booking(booking_id=session.booking_id) + + assert booking is not None + assert booking.id is not None + assert booking.description == booking_description + assert booking.started_at is not None + assert booking.finished_at is not None + assert booking.status in ["validated", "waiting", "validating"] + + while True: + time.sleep(2) + booking = client.get_booking(booking_id=session.booking_id) + + assert booking.status in ["starting", "running"] + assert booking.status in ["waiting", "validating", "validated"] + + if booking.status == "validated": + break + + finally: + client.delete_session(session.id) + + while True: + time.sleep(2) + booking = client.get_booking(booking_id=session.booking_id) def test_create_session_same_deduplication_id(): client = _get_client() @@ -199,62 +268,3 @@ def test_create_session_same_deduplication_id(): assert second_session.deduplication_id == session.deduplication_id finally: client.delete_session(session.id) - - -def test_run_process(): - client = _get_client() - - process_inputs = { - "Custom VQE": '{ "max_iterations": 1, "hamiltonian_strings" : ["XIIX", "ZZYY", "ZXYY", "ZZZZ"], "hamiltonian_weights" : [ -0.5, 1, 2.44, 5 ] }', - "CVar VQE": '{ "max_iterations": 3, "qubo_matrix" : [ [ 31, -500 ], [ -500, 32 ] ] }', - "Chemistry VQE": '{"max_iterations": 1, "geometry": [ {"coordinates": [ 0, 0, 0 ], "element": "Li" }, { "coordinates": [ 0, 0, 0.7414 ], "element": "H" }]}', - "H2 VQE": '{"max_iterations": 2, "geometry": [ {"coordinates": [ 0, 0, 0 ], "element": "H" }, { "coordinates": [ 0, 0, 0.7414 ], "element": "H" }]}', - "Graph Isomorphism": '{ "graph_a" : [ [ 0, 1 ], [ 1, 2 ], [2, 3], [2, 4], [3, 4] ], "graph_b" : [ [ 0, 1 ], [ 1, 2 ], [2, 3], [2, 4], [3, 4] ], "epsilon" : 10, "error" : 0.1, "algo" : "Laplacian PP", "max_iterations" : 3, "nb_samples" : 1000, "nb_samples_min_accepted" : 10}', - "Graph DSI": '{ "graph" : [ [ 0, 1 ], [ 1, 2 ], [2, 3], [2, 4], [3, 4] ], "max_iterations" : 10, "nb_samples" : 10000, "size_subgraph" : 3, "seed" : [ 0 ], "nb_samples_min_accepted" : 1000}', - } - - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert len(platforms) > 0 - - platform = platforms[0] - - if platform.provider_name != "quandela": - print("SKIP RUN PROCESS : ONLY QUANDELA PLATFORMS CAN RUN PROCESS") - return - - assert _TEST_APPLICATION_NAME in process_inputs - - applications = client.list_applications(name=_TEST_APPLICATION_NAME) - - assert len(applications) > 0 - - application = applications[0] - - process = client.create_process( - platform_id=platform.id, - application_id=application.id, - input=process_inputs[_TEST_APPLICATION_NAME], - ) - - assert process.platform_id == platform.id - assert process.application_id == application.id - assert process.status == "starting" - - assert process.input_ == process_inputs[_TEST_APPLICATION_NAME] - assert process.progress_message == "" - assert process.tags == [] - - while True: - time.sleep(3) - process = client.get_process(process.id) - assert process.status in [ - "starting", - "running", - "completed", - ] - print(process.progress, process.progress_message) - if process.status == "completed": - results = client.list_process_results(process.id) - assert len(results) > 0 - break From 7d37cc9fa65f3d0bb31f29d842861784e1dea127 Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Wed, 15 Oct 2025 18:25:15 +0200 Subject: [PATCH 04/13] feat(booking): wip booking testr --- scaleway_qaas_client/v1alpha1/client.py | 10 +- tests/test_api.py | 182 ++++++++++++++++++++++-- 2 files changed, 176 insertions(+), 16 deletions(-) diff --git a/scaleway_qaas_client/v1alpha1/client.py b/scaleway_qaas_client/v1alpha1/client.py index cb9d700..95974ee 100644 --- a/scaleway_qaas_client/v1alpha1/client.py +++ b/scaleway_qaas_client/v1alpha1/client.py @@ -306,7 +306,9 @@ def create_session( if booking_demand_started_at and booking_demand_finished_at: booking_demand_started_at_timestamp = booking_demand_started_at.timestamp() - booking_demand_finished_at_timestamp = booking_demand_finished_at.timestamp() + booking_demand_finished_at_timestamp = ( + booking_demand_finished_at.timestamp() + ) # seconds = int(booking_demand_started_at_timestamp) # nanos = int(booking_demand_started_at_timestamp % 1 * 1e9) @@ -1012,9 +1014,3 @@ def list_bookings( _raise_on_error(response) return response.parsed.bookings - - -# def _datetime_to_timestamp(time : datetime) -> Tuple[int, int]: -# timestamp = time.timestamp() -# seconds = int(timestamp) -# nanos = int(booking_demand_started_at_timestamp % 1 * 1e9) \ No newline at end of file diff --git a/tests/test_api.py b/tests/test_api.py index 3b69b35..3fea761 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -172,18 +172,19 @@ def test_list_platform_bookings(): assert len(bookings) > 0 + def test_create_and_cancel_booking(): client = _get_client() - try: - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 + assert len(platforms) > 0 - target_platform = platforms[0] + target_platform = platforms[0] + try: now = datetime.now(timezone.utc) - booking_start = now + timedelta(days=7) + booking_start = now + timedelta(seconds=15) booking_finish = booking_start + timedelta(hours=1) booking_description = "my lovely booking" @@ -191,7 +192,7 @@ def test_create_and_cancel_booking(): platform_id=target_platform.id, booking_demand_started_at=booking_start, booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description + booking_demand_description=booking_description, ) assert session is not None @@ -210,9 +211,12 @@ def test_create_and_cancel_booking(): while True: time.sleep(2) + session = client.get_session(session_id=session.id) booking = client.get_booking(booking_id=session.booking_id) - assert booking.status in ["starting", "running"] + print(session.status, booking.status) + + assert session.status in ["starting", "running"] assert booking.status in ["waiting", "validating", "validated"] if booking.status == "validated": @@ -231,8 +235,6 @@ def test_create_session_same_deduplication_id(): try: platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 - platform = platforms[0] max_duration = "2m" @@ -268,3 +270,165 @@ def test_create_session_same_deduplication_id(): assert second_session.deduplication_id == session.deduplication_id finally: client.delete_session(session.id) + + +def test_create_overlaping_booking(): + client = _get_client() + + try: + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(days=1) + booking_finish = booking_start + timedelta(hours=1) + booking_description = "my overlaping booking" + + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + assert session == None + finally: + client.delete_session(session.id) + + +def test_create_too_long_booking(): + client = _get_client() + + try: + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(minutes=1) + booking_finish = booking_start + timedelta(hours=10) + booking_description = "my too long booking" + + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + assert session == None + finally: + client.delete_session(session.id) + + +def test_create_too_short_booking(): + client = _get_client() + + try: + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(minutes=1) + booking_finish = booking_start + timedelta(seconds=10) + booking_description = "my lovely booking" + + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + assert session == None + finally: + client.delete_session(session.id) + + +def test_create_too_short_booking(): + client = _get_client() + + try: + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(minutes=1) + booking_finish = booking_start + timedelta(seconds=10) + booking_description = "my lovely booking" + + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + assert session == None + finally: + client.delete_session(session.id) + + +def test_create_too_far_booking(): + client = _get_client() + + try: + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(days=30) + booking_finish = booking_start + timedelta(hours=2) + booking_description = "my lovely booking" + + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + assert session == None + finally: + client.delete_session(session.id) + + +def test_create_too_close_booking(): + client = _get_client() + + try: + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=10) + booking_finish = booking_start + timedelta(hours=2) + booking_description = "my lovely booking" + + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + assert session == None + finally: + client.delete_session(session.id) From cc5b55c7c3a68fb8b836f2a9d1780de51c5d7108 Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Thu, 16 Oct 2025 14:48:31 +0200 Subject: [PATCH 05/13] feat(booking): wip booking test --- tests/test_api.py | 238 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 165 insertions(+), 73 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 3fea761..091b036 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -185,7 +185,7 @@ def test_create_and_cancel_booking(): try: now = datetime.now(timezone.utc) booking_start = now + timedelta(seconds=15) - booking_finish = booking_start + timedelta(hours=1) + booking_finish = booking_start + timedelta(seconds=20) booking_description = "my lovely booking" session = client.create_session( @@ -275,18 +275,18 @@ def test_create_session_same_deduplication_id(): def test_create_overlaping_booking(): client = _get_client() - try: - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 + assert len(platforms) > 0 - target_platform = platforms[0] + target_platform = platforms[0] - now = datetime.now(timezone.utc) - booking_start = now + timedelta(days=1) - booking_finish = booking_start + timedelta(hours=1) - booking_description = "my overlaping booking" + now = datetime.now(timezone.utc) + booking_start = now + timedelta(days=1) + booking_finish = booking_start + timedelta(hours=1) + booking_description = "my overlaping booking" + try: session = client.create_session( platform_id=target_platform.id, booking_demand_started_at=booking_start, @@ -295,140 +295,232 @@ def test_create_overlaping_booking(): ) assert session == None - finally: - client.delete_session(session.id) + except Exception as e: + assert "existing booking" in str(e) def test_create_too_long_booking(): client = _get_client() - try: - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 + assert len(platforms) > 0 - target_platform = platforms[0] + target_platform = platforms[0] - now = datetime.now(timezone.utc) - booking_start = now + timedelta(minutes=1) - booking_finish = booking_start + timedelta(hours=10) - booking_description = "my too long booking" + now = datetime.now(timezone.utc) + booking_start = now + timedelta(minutes=1) + booking_finish = booking_start + timedelta(hours=10) + booking_description = "my too long booking" - session = client.create_session( + try: + _ = client.create_session( platform_id=target_platform.id, booking_demand_started_at=booking_start, booking_demand_finished_at=booking_finish, booking_demand_description=booking_description, ) - - assert session == None - finally: - client.delete_session(session.id) + except Exception as e: + assert "max_duration not respected" in str(e) def test_create_too_short_booking(): client = _get_client() - try: - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 + assert len(platforms) > 0 - target_platform = platforms[0] + target_platform = platforms[0] - now = datetime.now(timezone.utc) - booking_start = now + timedelta(minutes=1) - booking_finish = booking_start + timedelta(seconds=10) - booking_description = "my lovely booking" + now = datetime.now(timezone.utc) + booking_start = now + timedelta(minutes=1) + booking_finish = booking_start + timedelta(seconds=10) + booking_description = "my lovely booking" - session = client.create_session( + try: + _ = client.create_session( platform_id=target_platform.id, booking_demand_started_at=booking_start, booking_demand_finished_at=booking_finish, booking_demand_description=booking_description, ) - - assert session == None - finally: - client.delete_session(session.id) + except Exception as e: + assert "min_duration not respected" in str(e) -def test_create_too_short_booking(): +def test_create_too_far_booking(): client = _get_client() - try: - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 + assert len(platforms) > 0 - target_platform = platforms[0] + target_platform = platforms[0] - now = datetime.now(timezone.utc) - booking_start = now + timedelta(minutes=1) - booking_finish = booking_start + timedelta(seconds=10) - booking_description = "my lovely booking" + now = datetime.now(timezone.utc) + booking_start = now + timedelta(days=30) + booking_finish = booking_start + timedelta(hours=2) + booking_description = "my lovely booking" - session = client.create_session( + try: + _ = client.create_session( platform_id=target_platform.id, booking_demand_started_at=booking_start, booking_demand_finished_at=booking_finish, booking_demand_description=booking_description, ) - - assert session == None - finally: - client.delete_session(session.id) + except Exception as e: + assert "max_planification_duration not respected" in str(e) -def test_create_too_far_booking(): +def test_create_too_close_booking(): client = _get_client() - try: - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 + assert len(platforms) > 0 - target_platform = platforms[0] + target_platform = platforms[0] - now = datetime.now(timezone.utc) - booking_start = now + timedelta(days=30) - booking_finish = booking_start + timedelta(hours=2) - booking_description = "my lovely booking" + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=10) + booking_finish = booking_start + timedelta(hours=2) + booking_description = "my lovely booking" - session = client.create_session( + try: + _ = client.create_session( platform_id=target_platform.id, booking_demand_started_at=booking_start, booking_demand_finished_at=booking_finish, booking_demand_description=booking_description, ) + except Exception as e: + assert "min_planification_duration not respected" in str(e) - assert session == None - finally: - client.delete_session(session.id) +def test_cannot_start_not_booked_session_during_booked_session_is_running(): + client = _get_client() -def test_create_too_close_booking(): + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=20) + booking_finish = booking_start + timedelta(seconds=20) + booking_description = "my booking" + + booked_session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + time.sleep(23) + + not_booked_session = client.create_session( + platform_id=target_platform.id, + ) + + while True: + time.sleep(2) + not_booked_session = client.get_session(session_id=not_booked_session.id) + + booked_session = client.get_session(session_id=booked_session.id) + + assert not_booked_session.status in ["starting"] + assert booked_session.status in ["starting", "running", "stopping", "stopped"] + + if booked_session.status == "stopped": + break + + while True: + time.sleep(2) + not_booked_session = client.get_session(session_id=not_booked_session.id) + + assert not_booked_session.status in ["starting", "running"] + + if booked_session.status == "running": + break + + client.delete_session(not_booked_session.id) + + +def test_not_booked_session_is_killed_when_booked_session_starts(): client = _get_client() + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + try: - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + not_booked_session_1 = client.create_session( + platform_id=target_platform.id, + ) - assert len(platforms) > 0 + assert not_booked_session_1 - target_platform = platforms[0] + not_booked_session_2 = client.create_session( + platform_id=target_platform.id, + ) + + assert not_booked_session_2 now = datetime.now(timezone.utc) - booking_start = now + timedelta(seconds=10) - booking_finish = booking_start + timedelta(hours=2) - booking_description = "my lovely booking" + booking_start = now + timedelta(seconds=20) + booking_finish = booking_start + timedelta(seconds=20) + booking_description = "my booking" - session = client.create_session( + booked_session = client.create_session( platform_id=target_platform.id, booking_demand_started_at=booking_start, booking_demand_finished_at=booking_finish, booking_demand_description=booking_description, ) - assert session == None + while True: + time.sleep(2) + not_booked_session_1 = client.get_session( + session_id=not_booked_session_1.id + ) + not_booked_session_2 = client.get_session( + session_id=not_booked_session_2.id + ) + + assert not_booked_session_1.status in ["starting", "running"] + assert not_booked_session_2.status in ["starting", "running"] + + if ( + not_booked_session_1.status == "running" + and not_booked_session_2.status == "running" + ): + break + + time.sleep(25) + + while True: + time.sleep(2) + not_booked_session_1 = client.get_session( + session_id=not_booked_session_1.id + ) + not_booked_session_2 = client.get_session( + session_id=not_booked_session_2.id + ) + + assert not_booked_session_1.status in ["running", "stopping", "stopped"] + assert not_booked_session_2.status in ["running", "stopping", "stopped"] + + if ( + not_booked_session_1.status == "stopped" + and not_booked_session_2.status == "stopped" + ): + break + finally: client.delete_session(session.id) From 3e7c8c7ed963fd2a736b7a0244a76485938e4f70 Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Thu, 16 Oct 2025 18:50:30 +0200 Subject: [PATCH 06/13] feat(booking): wip booking test --- tests/test_api.py | 401 +++++++++++++++++++++++----------------------- 1 file changed, 202 insertions(+), 199 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 091b036..ddaaa5c 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -173,61 +173,61 @@ def test_list_platform_bookings(): assert len(bookings) > 0 -def test_create_and_cancel_booking(): - client = _get_client() +# def test_create_and_cancel_booking(): +# client = _get_client() - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) +# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 +# assert len(platforms) > 0 - target_platform = platforms[0] +# target_platform = platforms[0] - try: - now = datetime.now(timezone.utc) - booking_start = now + timedelta(seconds=15) - booking_finish = booking_start + timedelta(seconds=20) - booking_description = "my lovely booking" +# try: +# now = datetime.now(timezone.utc) +# booking_start = now + timedelta(seconds=15) +# booking_finish = booking_start + timedelta(seconds=20) +# booking_description = "my lovely booking" - session = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) +# session = client.create_session( +# platform_id=target_platform.id, +# booking_demand_started_at=booking_start, +# booking_demand_finished_at=booking_finish, +# booking_demand_description=booking_description, +# ) - assert session is not None - assert session.id is not None - assert session.platform_id == target_platform.id - assert session.booking_id is not None +# assert session is not None +# assert session.id is not None +# assert session.platform_id == target_platform.id +# assert session.booking_id is not None - booking = client.get_booking(booking_id=session.booking_id) +# booking = client.get_booking(booking_id=session.booking_id) - assert booking is not None - assert booking.id is not None - assert booking.description == booking_description - assert booking.started_at is not None - assert booking.finished_at is not None - assert booking.status in ["validated", "waiting", "validating"] +# assert booking is not None +# assert booking.id is not None +# assert booking.description == booking_description +# assert booking.started_at is not None +# assert booking.finished_at is not None +# assert booking.status in ["validated", "waiting", "validating"] - while True: - time.sleep(2) - session = client.get_session(session_id=session.id) - booking = client.get_booking(booking_id=session.booking_id) +# while True: +# time.sleep(2) +# session = client.get_session(session_id=session.id) +# booking = client.get_booking(booking_id=session.booking_id) - print(session.status, booking.status) +# print(session.status, booking.status) - assert session.status in ["starting", "running"] - assert booking.status in ["waiting", "validating", "validated"] +# assert session.status in ["starting", "running"] +# assert booking.status in ["waiting", "validating", "validated"] - if booking.status == "validated": - break +# if booking.status == "validated": +# break - finally: - client.delete_session(session.id) +# finally: +# client.delete_session(session.id) - while True: - time.sleep(2) - booking = client.get_booking(booking_id=session.booking_id) +# while True: +# time.sleep(2) +# booking = client.get_booking(booking_id=session.booking_id) def test_create_session_same_deduplication_id(): client = _get_client() @@ -272,131 +272,131 @@ def test_create_session_same_deduplication_id(): client.delete_session(session.id) -def test_create_overlaping_booking(): - client = _get_client() +# def test_create_overlaping_booking(): +# client = _get_client() - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) +# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 +# assert len(platforms) > 0 - target_platform = platforms[0] +# target_platform = platforms[0] - now = datetime.now(timezone.utc) - booking_start = now + timedelta(days=1) - booking_finish = booking_start + timedelta(hours=1) - booking_description = "my overlaping booking" +# now = datetime.now(timezone.utc) +# booking_start = now + timedelta(days=1) +# booking_finish = booking_start + timedelta(hours=1) +# booking_description = "my overlaping booking" - try: - session = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) +# try: +# session = client.create_session( +# platform_id=target_platform.id, +# booking_demand_started_at=booking_start, +# booking_demand_finished_at=booking_finish, +# booking_demand_description=booking_description, +# ) - assert session == None - except Exception as e: - assert "existing booking" in str(e) +# assert session == None +# except Exception as e: +# assert "existing booking" in str(e) -def test_create_too_long_booking(): - client = _get_client() +# def test_create_too_long_booking(): +# client = _get_client() - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) +# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 +# assert len(platforms) > 0 - target_platform = platforms[0] +# target_platform = platforms[0] - now = datetime.now(timezone.utc) - booking_start = now + timedelta(minutes=1) - booking_finish = booking_start + timedelta(hours=10) - booking_description = "my too long booking" +# now = datetime.now(timezone.utc) +# booking_start = now + timedelta(minutes=1) +# booking_finish = booking_start + timedelta(hours=10) +# booking_description = "my too long booking" - try: - _ = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - except Exception as e: - assert "max_duration not respected" in str(e) +# try: +# _ = client.create_session( +# platform_id=target_platform.id, +# booking_demand_started_at=booking_start, +# booking_demand_finished_at=booking_finish, +# booking_demand_description=booking_description, +# ) +# except Exception as e: +# assert "max_duration not respected" in str(e) -def test_create_too_short_booking(): - client = _get_client() +# def test_create_too_short_booking(): +# client = _get_client() - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) +# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 +# assert len(platforms) > 0 - target_platform = platforms[0] +# target_platform = platforms[0] - now = datetime.now(timezone.utc) - booking_start = now + timedelta(minutes=1) - booking_finish = booking_start + timedelta(seconds=10) - booking_description = "my lovely booking" +# now = datetime.now(timezone.utc) +# booking_start = now + timedelta(minutes=1) +# booking_finish = booking_start + timedelta(seconds=10) +# booking_description = "my lovely booking" - try: - _ = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - except Exception as e: - assert "min_duration not respected" in str(e) +# try: +# _ = client.create_session( +# platform_id=target_platform.id, +# booking_demand_started_at=booking_start, +# booking_demand_finished_at=booking_finish, +# booking_demand_description=booking_description, +# ) +# except Exception as e: +# assert "min_duration not respected" in str(e) -def test_create_too_far_booking(): - client = _get_client() +# def test_create_too_far_booking(): +# client = _get_client() - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) +# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 +# assert len(platforms) > 0 - target_platform = platforms[0] +# target_platform = platforms[0] - now = datetime.now(timezone.utc) - booking_start = now + timedelta(days=30) - booking_finish = booking_start + timedelta(hours=2) - booking_description = "my lovely booking" +# now = datetime.now(timezone.utc) +# booking_start = now + timedelta(days=30) +# booking_finish = booking_start + timedelta(hours=2) +# booking_description = "my lovely booking" - try: - _ = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - except Exception as e: - assert "max_planification_duration not respected" in str(e) +# try: +# _ = client.create_session( +# platform_id=target_platform.id, +# booking_demand_started_at=booking_start, +# booking_demand_finished_at=booking_finish, +# booking_demand_description=booking_description, +# ) +# except Exception as e: +# assert "max_planification_duration not respected" in str(e) -def test_create_too_close_booking(): - client = _get_client() +# def test_create_too_close_booking(): +# client = _get_client() - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) +# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 +# assert len(platforms) > 0 - target_platform = platforms[0] +# target_platform = platforms[0] - now = datetime.now(timezone.utc) - booking_start = now + timedelta(seconds=10) - booking_finish = booking_start + timedelta(hours=2) - booking_description = "my lovely booking" +# now = datetime.now(timezone.utc) +# booking_start = now + timedelta(seconds=10) +# booking_finish = booking_start + timedelta(hours=2) +# booking_description = "my lovely booking" - try: - _ = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - except Exception as e: - assert "min_planification_duration not respected" in str(e) +# try: +# _ = client.create_session( +# platform_id=target_platform.id, +# booking_demand_started_at=booking_start, +# booking_demand_finished_at=booking_finish, +# booking_demand_description=booking_description, +# ) +# except Exception as e: +# assert "min_planification_duration not respected" in str(e) def test_cannot_start_not_booked_session_during_booked_session_is_running(): @@ -420,7 +420,14 @@ def test_cannot_start_not_booked_session_during_booked_session_is_running(): booking_demand_description=booking_description, ) - time.sleep(23) + while True: + time.sleep(2) + booked_session = client.get_session(session_id=booked_session.id) + + assert booked_session.status in ["starting", "running"] + + if booked_session.status == "running": + break not_booked_session = client.create_session( platform_id=target_platform.id, @@ -429,11 +436,10 @@ def test_cannot_start_not_booked_session_during_booked_session_is_running(): while True: time.sleep(2) not_booked_session = client.get_session(session_id=not_booked_session.id) - booked_session = client.get_session(session_id=booked_session.id) assert not_booked_session.status in ["starting"] - assert booked_session.status in ["starting", "running", "stopping", "stopped"] + assert booked_session.status in ["running", "stopping", "stopped"] if booked_session.status == "stopped": break @@ -444,83 +450,80 @@ def test_cannot_start_not_booked_session_during_booked_session_is_running(): assert not_booked_session.status in ["starting", "running"] - if booked_session.status == "running": + if not_booked_session.status == "running": break client.delete_session(not_booked_session.id) -def test_not_booked_session_is_killed_when_booked_session_starts(): - client = _get_client() +# def test_not_booked_session_is_killed_when_booked_session_starts(): +# client = _get_client() - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) +# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - assert len(platforms) > 0 +# assert len(platforms) > 0 - target_platform = platforms[0] +# target_platform = platforms[0] - try: - not_booked_session_1 = client.create_session( - platform_id=target_platform.id, - ) +# try: +# not_booked_session_1 = client.create_session( +# platform_id=target_platform.id, +# ) - assert not_booked_session_1 +# assert not_booked_session_1 - not_booked_session_2 = client.create_session( - platform_id=target_platform.id, - ) +# not_booked_session_2 = client.create_session( +# platform_id=target_platform.id, +# ) - assert not_booked_session_2 +# assert not_booked_session_2 - now = datetime.now(timezone.utc) - booking_start = now + timedelta(seconds=20) - booking_finish = booking_start + timedelta(seconds=20) - booking_description = "my booking" +# now = datetime.now(timezone.utc) +# booking_start = now + timedelta(seconds=20) +# booking_finish = booking_start + timedelta(seconds=20) +# booking_description = "my booking" - booked_session = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) +# booked_session = client.create_session( +# platform_id=target_platform.id, +# booking_demand_started_at=booking_start, +# booking_demand_finished_at=booking_finish, +# booking_demand_description=booking_description, +# ) - while True: - time.sleep(2) - not_booked_session_1 = client.get_session( - session_id=not_booked_session_1.id - ) - not_booked_session_2 = client.get_session( - session_id=not_booked_session_2.id - ) - - assert not_booked_session_1.status in ["starting", "running"] - assert not_booked_session_2.status in ["starting", "running"] - - if ( - not_booked_session_1.status == "running" - and not_booked_session_2.status == "running" - ): - break - - time.sleep(25) - - while True: - time.sleep(2) - not_booked_session_1 = client.get_session( - session_id=not_booked_session_1.id - ) - not_booked_session_2 = client.get_session( - session_id=not_booked_session_2.id - ) - - assert not_booked_session_1.status in ["running", "stopping", "stopped"] - assert not_booked_session_2.status in ["running", "stopping", "stopped"] - - if ( - not_booked_session_1.status == "stopped" - and not_booked_session_2.status == "stopped" - ): - break +# while True: +# time.sleep(2) +# not_booked_session_1 = client.get_session( +# session_id=not_booked_session_1.id +# ) +# not_booked_session_2 = client.get_session( +# session_id=not_booked_session_2.id +# ) - finally: - client.delete_session(session.id) +# assert not_booked_session_1.status in ["starting", "running"] +# assert not_booked_session_2.status in ["starting", "running"] + +# if ( +# not_booked_session_1.status == "running" +# and not_booked_session_2.status == "running" +# ): +# break + +# time.sleep(25) + +# while True: +# time.sleep(2) +# not_booked_session_1 = client.get_session( +# session_id=not_booked_session_1.id +# ) +# not_booked_session_2 = client.get_session( +# session_id=not_booked_session_2.id +# ) + +# assert not_booked_session_1.status in ["running", "stopping", "stopped"] +# assert not_booked_session_2.status in ["running", "stopping", "stopped"] + +# if ( +# not_booked_session_1.status == "stopped" +# and not_booked_session_2.status == "stopped" +# ): +# break From 2f0b9399621cc67c243bc1db9bf5602d7cdaf946 Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Fri, 17 Oct 2025 19:02:48 +0200 Subject: [PATCH 07/13] feat(booking): ok booking test --- tests/test_api.py | 503 +++++++++++++++++++++++++++++----------------- 1 file changed, 320 insertions(+), 183 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index ddaaa5c..d2892ba 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -173,62 +173,63 @@ def test_list_platform_bookings(): assert len(bookings) > 0 -# def test_create_and_cancel_booking(): -# client = _get_client() +def test_create_and_cancel_booking(): + client = _get_client() -# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) -# assert len(platforms) > 0 + assert len(platforms) > 0 -# target_platform = platforms[0] + target_platform = platforms[0] -# try: -# now = datetime.now(timezone.utc) -# booking_start = now + timedelta(seconds=15) -# booking_finish = booking_start + timedelta(seconds=20) -# booking_description = "my lovely booking" + try: + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=15) + booking_finish = booking_start + timedelta(seconds=20) + booking_description = "my lovely booking" -# session = client.create_session( -# platform_id=target_platform.id, -# booking_demand_started_at=booking_start, -# booking_demand_finished_at=booking_finish, -# booking_demand_description=booking_description, -# ) + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) -# assert session is not None -# assert session.id is not None -# assert session.platform_id == target_platform.id -# assert session.booking_id is not None + assert session is not None + assert session.id is not None + assert session.platform_id == target_platform.id + assert session.booking_id is not None -# booking = client.get_booking(booking_id=session.booking_id) + booking = client.get_booking(booking_id=session.booking_id) -# assert booking is not None -# assert booking.id is not None -# assert booking.description == booking_description -# assert booking.started_at is not None -# assert booking.finished_at is not None -# assert booking.status in ["validated", "waiting", "validating"] + assert booking is not None + assert booking.id is not None + assert booking.description == booking_description + assert booking.started_at is not None + assert booking.finished_at is not None + assert booking.status in ["validated", "waiting", "validating"] -# while True: -# time.sleep(2) -# session = client.get_session(session_id=session.id) -# booking = client.get_booking(booking_id=session.booking_id) + while True: + time.sleep(2) + session = client.get_session(session_id=session.id) + booking = client.get_booking(booking_id=session.booking_id) -# print(session.status, booking.status) + print(session.status, booking.status) -# assert session.status in ["starting", "running"] -# assert booking.status in ["waiting", "validating", "validated"] + assert session.status in ["starting", "running"] + assert booking.status in ["waiting", "validating", "validated"] -# if booking.status == "validated": -# break + if booking.status == "validated": + break -# finally: -# client.delete_session(session.id) + finally: + client.delete_session(session.id) -# while True: -# time.sleep(2) -# booking = client.get_booking(booking_id=session.booking_id) + while True: + time.sleep(2) + booking = client.get_booking(booking_id=session.booking_id) +<<<<<<< HEAD def test_create_session_same_deduplication_id(): client = _get_client() @@ -270,133 +271,187 @@ def test_create_session_same_deduplication_id(): assert second_session.deduplication_id == session.deduplication_id finally: client.delete_session(session.id) +======= + print(booking.status) + + assert booking.status in ["validated", "cancelling", "cancelled"] + + if booking.status == "cancelled": + break +>>>>>>> f758e18 (feat(booking): ok booking test) + + +def test_create_overlaping_booking(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(days=1) + booking_finish = booking_start + timedelta(hours=1) + booking_description = "my overlaping booking" + + try: + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + assert session == None + except Exception as e: + assert "existing booking" in str(e) + + +def test_create_too_long_booking(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + target_platform = platforms[0] -# def test_create_overlaping_booking(): -# client = _get_client() + now = datetime.now(timezone.utc) + booking_start = now + timedelta(minutes=1) + booking_finish = booking_start + timedelta(hours=10) + booking_description = "my too long booking" -# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + try: + _ = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + except Exception as e: + assert "max_duration not respected" in str(e) -# assert len(platforms) > 0 -# target_platform = platforms[0] +def test_create_too_short_booking(): + client = _get_client() -# now = datetime.now(timezone.utc) -# booking_start = now + timedelta(days=1) -# booking_finish = booking_start + timedelta(hours=1) -# booking_description = "my overlaping booking" + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) -# try: -# session = client.create_session( -# platform_id=target_platform.id, -# booking_demand_started_at=booking_start, -# booking_demand_finished_at=booking_finish, -# booking_demand_description=booking_description, -# ) + assert len(platforms) > 0 -# assert session == None -# except Exception as e: -# assert "existing booking" in str(e) + target_platform = platforms[0] + now = datetime.now(timezone.utc) + booking_start = now + timedelta(minutes=1) + booking_finish = booking_start + timedelta(seconds=10) + booking_description = "my lovely booking" -# def test_create_too_long_booking(): -# client = _get_client() + try: + _ = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + except Exception as e: + assert "min_duration not respected" in str(e) -# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) -# assert len(platforms) > 0 +def test_create_too_far_booking(): + client = _get_client() -# target_platform = platforms[0] + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) -# now = datetime.now(timezone.utc) -# booking_start = now + timedelta(minutes=1) -# booking_finish = booking_start + timedelta(hours=10) -# booking_description = "my too long booking" + assert len(platforms) > 0 -# try: -# _ = client.create_session( -# platform_id=target_platform.id, -# booking_demand_started_at=booking_start, -# booking_demand_finished_at=booking_finish, -# booking_demand_description=booking_description, -# ) -# except Exception as e: -# assert "max_duration not respected" in str(e) + target_platform = platforms[0] + now = datetime.now(timezone.utc) + booking_start = now + timedelta(days=30) + booking_finish = booking_start + timedelta(hours=2) + booking_description = "my lovely booking" -# def test_create_too_short_booking(): -# client = _get_client() + try: + _ = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + except Exception as e: + assert "max_planification_duration not respected" in str(e) -# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) -# assert len(platforms) > 0 +def test_create_too_close_booking(): + client = _get_client() -# target_platform = platforms[0] + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) -# now = datetime.now(timezone.utc) -# booking_start = now + timedelta(minutes=1) -# booking_finish = booking_start + timedelta(seconds=10) -# booking_description = "my lovely booking" + assert len(platforms) > 0 -# try: -# _ = client.create_session( -# platform_id=target_platform.id, -# booking_demand_started_at=booking_start, -# booking_demand_finished_at=booking_finish, -# booking_demand_description=booking_description, -# ) -# except Exception as e: -# assert "min_duration not respected" in str(e) + target_platform = platforms[0] + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=10) + booking_finish = booking_start + timedelta(hours=2) + booking_description = "my lovely booking" -# def test_create_too_far_booking(): -# client = _get_client() + try: + _ = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + except Exception as e: + assert "min_planification_duration not respected" in str(e) -# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) -# assert len(platforms) > 0 +def test_stop_too_close_booking(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=20) + booking_finish = booking_start + timedelta(seconds=30) + booking_description = "my lovely booking" -# target_platform = platforms[0] + try: + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) -# now = datetime.now(timezone.utc) -# booking_start = now + timedelta(days=30) -# booking_finish = booking_start + timedelta(hours=2) -# booking_description = "my lovely booking" + time.sleep(15) -# try: -# _ = client.create_session( -# platform_id=target_platform.id, -# booking_demand_started_at=booking_start, -# booking_demand_finished_at=booking_finish, -# booking_demand_description=booking_description, -# ) -# except Exception as e: -# assert "max_planification_duration not respected" in str(e) + session = client.terminate_session(session.id) + while True: + session = client.get_session(session.id) -# def test_create_too_close_booking(): -# client = _get_client() + assert session.status in ["starting", "running"] -# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + if session.status == "running": + break -# assert len(platforms) > 0 + except Exception as e: + assert "max_cancellation_time passed" in str(e) -# target_platform = platforms[0] + while True: + session = client.get_session(session.id) -# now = datetime.now(timezone.utc) -# booking_start = now + timedelta(seconds=10) -# booking_finish = booking_start + timedelta(hours=2) -# booking_description = "my lovely booking" + assert session.status in ["starting", "running", "stopped"] -# try: -# _ = client.create_session( -# platform_id=target_platform.id, -# booking_demand_started_at=booking_start, -# booking_demand_finished_at=booking_finish, -# booking_demand_description=booking_description, -# ) -# except Exception as e: -# assert "min_planification_duration not respected" in str(e) + if session.status == "stopped": + break def test_cannot_start_not_booked_session_during_booked_session_is_running(): @@ -438,7 +493,11 @@ def test_cannot_start_not_booked_session_during_booked_session_is_running(): not_booked_session = client.get_session(session_id=not_booked_session.id) booked_session = client.get_session(session_id=booked_session.id) - assert not_booked_session.status in ["starting"] + assert ( + not_booked_session.status == "starting" + if booked_session.status == "running" + else "running" + ) assert booked_session.status in ["running", "stopping", "stopped"] if booked_session.status == "stopped": @@ -456,74 +515,152 @@ def test_cannot_start_not_booked_session_during_booked_session_is_running(): client.delete_session(not_booked_session.id) -# def test_not_booked_session_is_killed_when_booked_session_starts(): -# client = _get_client() +def test_not_booked_session_is_killed_when_booked_session_starts(): + client = _get_client() -# platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) -# assert len(platforms) > 0 + assert len(platforms) > 0 -# target_platform = platforms[0] + target_platform = platforms[0] -# try: -# not_booked_session_1 = client.create_session( -# platform_id=target_platform.id, -# ) + try: + not_booked_session_1 = client.create_session( + platform_id=target_platform.id, + ) -# assert not_booked_session_1 + assert not_booked_session_1 -# not_booked_session_2 = client.create_session( -# platform_id=target_platform.id, -# ) + not_booked_session_2 = client.create_session( + platform_id=target_platform.id, + ) -# assert not_booked_session_2 + assert not_booked_session_2 -# now = datetime.now(timezone.utc) -# booking_start = now + timedelta(seconds=20) -# booking_finish = booking_start + timedelta(seconds=20) -# booking_description = "my booking" + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=20) + booking_finish = booking_start + timedelta(seconds=20) + booking_description = "my booking" -# booked_session = client.create_session( -# platform_id=target_platform.id, -# booking_demand_started_at=booking_start, -# booking_demand_finished_at=booking_finish, -# booking_demand_description=booking_description, -# ) + booked_session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) -# while True: -# time.sleep(2) -# not_booked_session_1 = client.get_session( -# session_id=not_booked_session_1.id -# ) -# not_booked_session_2 = client.get_session( -# session_id=not_booked_session_2.id -# ) + while True: + time.sleep(2) -# assert not_booked_session_1.status in ["starting", "running"] -# assert not_booked_session_2.status in ["starting", "running"] + not_booked_session_1 = client.get_session( + session_id=not_booked_session_1.id + ) + not_booked_session_2 = client.get_session( + session_id=not_booked_session_2.id + ) + booked_session = client.get_session(session_id=booked_session.id) -# if ( -# not_booked_session_1.status == "running" -# and not_booked_session_2.status == "running" -# ): -# break + assert not_booked_session_1.status in ["starting", "running"] + assert not_booked_session_2.status in ["starting", "running"] + assert booked_session.status in ["starting"] -# time.sleep(25) + if ( + not_booked_session_1.status == "running" + and not_booked_session_2.status == "running" + ): + break -# while True: -# time.sleep(2) -# not_booked_session_1 = client.get_session( -# session_id=not_booked_session_1.id -# ) -# not_booked_session_2 = client.get_session( -# session_id=not_booked_session_2.id -# ) + while True: + time.sleep(2) -# assert not_booked_session_1.status in ["running", "stopping", "stopped"] -# assert not_booked_session_2.status in ["running", "stopping", "stopped"] + booked_session = client.get_session(session_id=booked_session.id) +<<<<<<< HEAD # if ( # not_booked_session_1.status == "stopped" # and not_booked_session_2.status == "stopped" # ): # break +======= + assert booked_session.status in ["starting", "running"] + + if booked_session.status == "running": + break + + while True: + time.sleep(2) + + not_booked_session_1 = client.get_session( + session_id=not_booked_session_1.id + ) + not_booked_session_2 = client.get_session( + session_id=not_booked_session_2.id + ) + + assert not_booked_session_1.status in ["running", "stopping", "stopped"] + assert not_booked_session_2.status in ["running", "stopping", "stopped"] + + if ( + not_booked_session_1.status == "stopped" + and not_booked_session_2.status == "stopped" + ): + break + + while True: + booked_session = client.get_session(booked_session.id) + + assert booked_session.status in ["running", "stopped"] + + if booked_session.status == "stopped": + break + + finally: + client.delete_session(not_booked_session_1.id) + client.delete_session(not_booked_session_2.id) + client.delete_session(booked_session.id) + + +def test_create_session_same_deduplication_id(): + client = _get_client() + + try: + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + platform = platforms[0] + + max_duration = "2m" + max_idle_duration = "2m" + deduplication_id = f"hihaaa-{_RANDOM_UUID}" + + session = client.create_session( + platform_id=platform.id, + max_duration=max_duration, + max_idle_duration=max_idle_duration, + deduplication_id=deduplication_id, + ) + + assert session is not None + assert session.id is not None + assert session.platform_id == platform.id + assert session.deduplication_id == deduplication_id + assert session.status in ["starting", "running"] + + second_session = client.create_session( + platform_id=platform.id, + deduplication_id=deduplication_id, + ) + + assert second_session != None + assert second_session.id == session.id + assert second_session.project_id == session.project_id + assert second_session.platform_id == session.platform_id + assert second_session.name == session.name + assert second_session.max_duration == session.max_duration + assert second_session.max_idle_duration == session.max_idle_duration + assert second_session.status in session.status + assert second_session.deduplication_id == session.deduplication_id + finally: + client.delete_session(session.id) +>>>>>>> f758e18 (feat(booking): ok booking test) From 580c43aaf341183db7d9125b49d6c100e39198d9 Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Fri, 17 Oct 2025 19:16:25 +0200 Subject: [PATCH 08/13] feat(booking): ok booking test --- tests/test_api.py | 93 ----------------------------------------------- 1 file changed, 93 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index d2892ba..b37d5c3 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -229,7 +229,6 @@ def test_create_and_cancel_booking(): time.sleep(2) booking = client.get_booking(booking_id=session.booking_id) -<<<<<<< HEAD def test_create_session_same_deduplication_id(): client = _get_client() @@ -271,14 +270,6 @@ def test_create_session_same_deduplication_id(): assert second_session.deduplication_id == session.deduplication_id finally: client.delete_session(session.id) -======= - print(booking.status) - - assert booking.status in ["validated", "cancelling", "cancelled"] - - if booking.status == "cancelled": - break ->>>>>>> f758e18 (feat(booking): ok booking test) def test_create_overlaping_booking(): @@ -575,92 +566,8 @@ def test_not_booked_session_is_killed_when_booked_session_starts(): booked_session = client.get_session(session_id=booked_session.id) -<<<<<<< HEAD # if ( # not_booked_session_1.status == "stopped" # and not_booked_session_2.status == "stopped" # ): # break -======= - assert booked_session.status in ["starting", "running"] - - if booked_session.status == "running": - break - - while True: - time.sleep(2) - - not_booked_session_1 = client.get_session( - session_id=not_booked_session_1.id - ) - not_booked_session_2 = client.get_session( - session_id=not_booked_session_2.id - ) - - assert not_booked_session_1.status in ["running", "stopping", "stopped"] - assert not_booked_session_2.status in ["running", "stopping", "stopped"] - - if ( - not_booked_session_1.status == "stopped" - and not_booked_session_2.status == "stopped" - ): - break - - while True: - booked_session = client.get_session(booked_session.id) - - assert booked_session.status in ["running", "stopped"] - - if booked_session.status == "stopped": - break - - finally: - client.delete_session(not_booked_session_1.id) - client.delete_session(not_booked_session_2.id) - client.delete_session(booked_session.id) - - -def test_create_session_same_deduplication_id(): - client = _get_client() - - try: - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert len(platforms) > 0 - - platform = platforms[0] - - max_duration = "2m" - max_idle_duration = "2m" - deduplication_id = f"hihaaa-{_RANDOM_UUID}" - - session = client.create_session( - platform_id=platform.id, - max_duration=max_duration, - max_idle_duration=max_idle_duration, - deduplication_id=deduplication_id, - ) - - assert session is not None - assert session.id is not None - assert session.platform_id == platform.id - assert session.deduplication_id == deduplication_id - assert session.status in ["starting", "running"] - - second_session = client.create_session( - platform_id=platform.id, - deduplication_id=deduplication_id, - ) - - assert second_session != None - assert second_session.id == session.id - assert second_session.project_id == session.project_id - assert second_session.platform_id == session.platform_id - assert second_session.name == session.name - assert second_session.max_duration == session.max_duration - assert second_session.max_idle_duration == session.max_idle_duration - assert second_session.status in session.status - assert second_session.deduplication_id == session.deduplication_id - finally: - client.delete_session(session.id) ->>>>>>> f758e18 (feat(booking): ok booking test) From 90043089554e71811c5156b4a0b603d1d4a12a6c Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Fri, 17 Oct 2025 19:19:51 +0200 Subject: [PATCH 09/13] feat(booking): ok booking test --- Makefile | 6 +- tests/test_api.py | 63 +++++-- tests/test_booking.py | 423 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 472 insertions(+), 20 deletions(-) create mode 100644 tests/test_booking.py diff --git a/Makefile b/Makefile index 8dbc619..af6e3c2 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,11 @@ install-test: .PHONY: test test: - pytest -s --showprogress -vv tests/ + pytest -s --showprogress -vv tests/test_api.py + +.PHONY: test-booking +test-booking: + pytest -s --showprogress -vv tests/test_booking.py .PHONY: all all: v1alpha1 \ No newline at end of file diff --git a/tests/test_api.py b/tests/test_api.py index b37d5c3..2f8de8a 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -15,12 +15,10 @@ import time import uuid -from datetime import datetime, timedelta, timezone from scaleway_qaas_client.v1alpha1 import QaaSClient _RANDOM_UUID = str(uuid.uuid4()) _TEST_PLATFORM_NAME = os.environ.get("TEST_PLATFORM_NAME", "aer_simulation_pop_c16m128") -_TEST_APPLICATION_NAME = os.environ.get("TEST_APPLICATION_NAME", "H2 VQE") def _get_client() -> QaaSClient: @@ -178,36 +176,62 @@ def test_create_and_cancel_booking(): platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + for platform in platforms: + assert platform.name == _TEST_PLATFORM_NAME + assert len(platforms) > 0 - target_platform = platforms[0] + +def test_list_platforms_by_unexisting_name(): + client = _get_client() + + platforms = client.list_platforms(name=_RANDOM_UUID) + + assert platforms == [] + + +def test_list_sessions_unexisting_platform(): + client = _get_client() + + sessions = client.list_sessions(platform_id=_RANDOM_UUID) + + assert sessions == [] + + +def test_create_delete_session(): + client = _get_client() try: - now = datetime.now(timezone.utc) - booking_start = now + timedelta(seconds=15) - booking_finish = booking_start + timedelta(seconds=20) - booking_description = "my lovely booking" + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert platforms is not None + assert len(platforms) == 1 + + target_platform = platforms[0] + + assert target_platform.id is not None + + max_duration = "2m" + max_idle_duration = "2m" session = client.create_session( platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, + max_duration=max_duration, + max_idle_duration=max_idle_duration, ) + print(session.updated_at) + print(session.created_at) + assert session is not None assert session.id is not None assert session.platform_id == target_platform.id - assert session.booking_id is not None - booking = client.get_booking(booking_id=session.booking_id) + while session.status == "starting": + session = client.get_session(session.id) + time.sleep(3) - assert booking is not None - assert booking.id is not None - assert booking.description == booking_description - assert booking.started_at is not None - assert booking.finished_at is not None - assert booking.status in ["validated", "waiting", "validating"] + assert session.status == "running" while True: time.sleep(2) @@ -425,8 +449,9 @@ def test_stop_too_close_booking(): session = client.terminate_session(session.id) - while True: + while session.status == "stopping": session = client.get_session(session.id) + time.sleep(3) assert session.status in ["starting", "running"] diff --git a/tests/test_booking.py b/tests/test_booking.py new file mode 100644 index 0000000..1534f5a --- /dev/null +++ b/tests/test_booking.py @@ -0,0 +1,423 @@ +# Copyright 2025 Scaleway +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +import os +import time +import uuid + +from datetime import datetime, timedelta, timezone +from scaleway_qaas_client.v1alpha1 import QaaSClient + +_TEST_PLATFORM_NAME = os.environ.get("TEST_PLATFORM_NAME", "aer_simulation_pop_c16m128") + + +def _get_client() -> QaaSClient: + client = QaaSClient( + project_id=os.environ["SCALEWAY_PROJECT_ID"], + secret_key=os.environ["SCALEWAY_SECRET_KEY"], + url=os.environ["SCALEWAY_API_URL"], + ) + + return client + + +def test_create_and_cancel_booking(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + try: + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=15) + booking_finish = booking_start + timedelta(seconds=20) + booking_description = "my lovely booking" + + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + assert session is not None + assert session.id is not None + assert session.platform_id == target_platform.id + assert session.booking_id is not None + + booking = client.get_booking(booking_id=session.booking_id) + + assert booking is not None + assert booking.id is not None + assert booking.description == booking_description + assert booking.started_at is not None + assert booking.finished_at is not None + assert booking.status in ["validated", "waiting", "validating"] + + while True: + time.sleep(2) + session = client.get_session(session_id=session.id) + booking = client.get_booking(booking_id=session.booking_id) + + assert session.status in ["starting", "running"] + assert booking.status in ["waiting", "validating", "validated"] + + if booking.status == "validated": + break + + finally: + client.delete_session(session.id) + + while True: + time.sleep(2) + booking = client.get_booking(booking_id=session.booking_id) + + assert booking.status in ["validated", "cancelling", "cancelled"] + + if booking.status == "cancelled": + break + + +def test_create_overlaping_booking(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(days=1) + booking_finish = booking_start + timedelta(hours=1) + booking_description = "my overlaping booking" + + try: + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + assert session == None + except Exception as e: + assert "existing booking" in str(e) + + +def test_create_too_long_booking(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(minutes=1) + booking_finish = booking_start + timedelta(hours=10) + booking_description = "my too long booking" + + try: + _ = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + except Exception as e: + assert "max_duration not respected" in str(e) + + +def test_create_too_short_booking(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(minutes=1) + booking_finish = booking_start + timedelta(seconds=10) + booking_description = "my lovely booking" + + try: + _ = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + except Exception as e: + assert "min_duration not respected" in str(e) + + +def test_create_too_far_booking(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(days=30) + booking_finish = booking_start + timedelta(hours=2) + booking_description = "my lovely booking" + + try: + _ = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + except Exception as e: + assert "max_planification_duration not respected" in str(e) + + +def test_create_too_close_booking(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=10) + booking_finish = booking_start + timedelta(hours=2) + booking_description = "my lovely booking" + + try: + _ = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + except Exception as e: + assert "min_planification_duration not respected" in str(e) + + +def test_stop_too_close_booking(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=20) + booking_finish = booking_start + timedelta(seconds=30) + booking_description = "my lovely booking" + + try: + session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + time.sleep(15) + + session = client.terminate_session(session.id) + + while True: + session = client.get_session(session.id) + + assert session.status in ["starting", "running"] + + if session.status == "running": + break + + except Exception as e: + assert "max_cancellation_time passed" in str(e) + + while True: + session = client.get_session(session.id) + + assert session.status in ["starting", "running", "stopped"] + + if session.status == "stopped": + break + + +def test_cannot_start_not_booked_session_during_booked_session_is_running(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=20) + booking_finish = booking_start + timedelta(seconds=20) + booking_description = "my booking" + + booked_session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + while True: + time.sleep(2) + booked_session = client.get_session(session_id=booked_session.id) + + assert booked_session.status in ["starting", "running"] + + if booked_session.status == "running": + break + + not_booked_session = client.create_session( + platform_id=target_platform.id, + ) + + while True: + time.sleep(2) + not_booked_session = client.get_session(session_id=not_booked_session.id) + booked_session = client.get_session(session_id=booked_session.id) + + assert ( + not_booked_session.status == "starting" + if booked_session.status == "running" + else "running" + ) + assert booked_session.status in ["running", "stopping", "stopped"] + + if booked_session.status == "stopped": + break + + while True: + time.sleep(2) + not_booked_session = client.get_session(session_id=not_booked_session.id) + + assert not_booked_session.status in ["starting", "running"] + + if not_booked_session.status == "running": + break + + client.delete_session(not_booked_session.id) + + +def test_not_booked_session_is_killed_when_booked_session_starts(): + client = _get_client() + + platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + + assert len(platforms) > 0 + + target_platform = platforms[0] + + try: + not_booked_session_1 = client.create_session( + platform_id=target_platform.id, + ) + + assert not_booked_session_1 + + not_booked_session_2 = client.create_session( + platform_id=target_platform.id, + ) + + assert not_booked_session_2 + + now = datetime.now(timezone.utc) + booking_start = now + timedelta(seconds=20) + booking_finish = booking_start + timedelta(seconds=20) + booking_description = "my booking" + + booked_session = client.create_session( + platform_id=target_platform.id, + booking_demand_started_at=booking_start, + booking_demand_finished_at=booking_finish, + booking_demand_description=booking_description, + ) + + while True: + time.sleep(2) + + not_booked_session_1 = client.get_session( + session_id=not_booked_session_1.id + ) + not_booked_session_2 = client.get_session( + session_id=not_booked_session_2.id + ) + booked_session = client.get_session(session_id=booked_session.id) + + assert not_booked_session_1.status in ["starting", "running"] + assert not_booked_session_2.status in ["starting", "running"] + assert booked_session.status in ["starting"] + + if ( + not_booked_session_1.status == "running" + and not_booked_session_2.status == "running" + ): + break + + while True: + time.sleep(2) + + booked_session = client.get_session(session_id=booked_session.id) + + assert booked_session.status in ["starting", "running"] + + if booked_session.status == "running": + break + + while True: + time.sleep(2) + + not_booked_session_1 = client.get_session( + session_id=not_booked_session_1.id + ) + not_booked_session_2 = client.get_session( + session_id=not_booked_session_2.id + ) + + assert not_booked_session_1.status in ["running", "stopping", "stopped"] + assert not_booked_session_2.status in ["running", "stopping", "stopped"] + + if ( + not_booked_session_1.status == "stopped" + and not_booked_session_2.status == "stopped" + ): + break + + while True: + booked_session = client.get_session(booked_session.id) + + assert booked_session.status in ["running", "stopped"] + + if booked_session.status == "stopped": + break + + finally: + client.delete_session(not_booked_session_1.id) + client.delete_session(not_booked_session_2.id) + client.delete_session(booked_session.id) From 7fd27f44ea6602119832c35b5ded7d6ed25ea1a7 Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Wed, 22 Oct 2025 12:21:46 +0200 Subject: [PATCH 10/13] feat(qaas): wip timezone --- openapi/scaleway.qaas.v1alpha1.Api.yml | 73 ++-------------- requirements.txt | 4 +- scaleway_qaas_client/v1alpha1/__init__.py | 12 +-- scaleway_qaas_client/v1alpha1/client.py | 16 +++- .../api/applications/get_application.py | 8 +- .../api/applications/list_applications.py | 56 ++++++------- .../api/bookings/get_booking.py | 8 +- .../api/bookings/list_bookings.py | 44 +++++----- .../api/bookings/update_booking.py | 8 +- .../api/jobs/cancel_job.py | 8 +- .../api/jobs/delete_job.py | 4 +- .../api/jobs/get_job.py | 8 +- .../api/jobs/get_job_circuit.py | 8 +- .../api/jobs/list_job_results.py | 40 ++++----- .../api/jobs/update_job.py | 8 +- .../api/models/get_model.py | 8 +- .../api/models/list_models.py | 36 ++++---- .../api/platforms/get_platform.py | 8 +- .../api/platforms/list_platforms.py | 84 +++++++++---------- .../api/processes/cancel_process.py | 8 +- .../api/processes/delete_process.py | 4 +- .../api/processes/get_process.py | 8 +- .../api/processes/list_process_results.py | 40 ++++----- .../api/processes/list_processes.py | 64 +++++++------- .../api/processes/update_process.py | 8 +- .../api/sessions/delete_session.py | 4 +- .../api/sessions/get_session.py | 8 +- .../api/sessions/list_sessions.py | 56 ++++++------- .../api/sessions/terminate_session.py | 8 +- .../api/sessions/update_session.py | 8 +- .../create_session_body_booking_demand.py | 20 +++++ .../scaleway_qaas_v1_alpha_1_booking.py | 21 +++++ scaleway_qaas_client/v1alpha1/utils.py | 20 +++++ tests/test_booking.py | 2 +- 34 files changed, 356 insertions(+), 364 deletions(-) create mode 100644 scaleway_qaas_client/v1alpha1/utils.py diff --git a/openapi/scaleway.qaas.v1alpha1.Api.yml b/openapi/scaleway.qaas.v1alpha1.Api.yml index c6e8e67..3222629 100644 --- a/openapi/scaleway.qaas.v1alpha1.Api.yml +++ b/openapi/scaleway.qaas.v1alpha1.Api.yml @@ -379,6 +379,11 @@ components: progress_message: type: string description: Any progress message of the booking. + time_zone: + type: string + description: Time zone for the booking schedule, in tz database format (e.g. + 'Europe/Paris'). + nullable: true x-properties-order: - id - created_at @@ -388,6 +393,7 @@ components: - status - description - progress_message + - time_zone scaleway.qaas.v1alpha1.Job: type: object properties: @@ -1191,13 +1197,11 @@ paths: description: List applications with this name. schema: type: string - description: List applications with this name. - in: query name: application_type description: List applications with this type. schema: type: string - description: List applications with this type. enum: - unknown_type - vqe @@ -1211,21 +1215,18 @@ paths: description: Page number. schema: type: integer - description: Page number. format: int32 - in: query name: page_size description: Maximum number of applications a to return per page. schema: type: integer - description: Maximum number of applications a to return per page. format: uint32 - in: query name: order_by description: Sort order of the returned applications. schema: type: string - description: Sort order of the returned applications. enum: - name_asc - name_desc @@ -1266,7 +1267,6 @@ paths: required: true schema: type: string - description: Unique ID of the application. responses: "200": description: "" @@ -1300,34 +1300,29 @@ paths: description: List bookings belonging to this project ID. (UUID format) schema: type: string - description: List bookings belonging to this project ID. (UUID format) example: 6170692e-7363-616c-6577-61792e636f6d - in: query name: platform_id description: List bookings attached to this platform ID. schema: type: string - description: List bookings attached to this platform ID. - in: query name: page description: Page number. schema: type: integer - description: Page number. format: int32 - in: query name: page_size description: Maximum number of results to return per page. schema: type: integer - description: Maximum number of results to return per page. format: uint32 - in: query name: order_by description: Sort order of the returned results. schema: type: string - description: Sort order of the returned results. enum: - created_at_desc - created_at_asc @@ -1368,7 +1363,6 @@ paths: required: true schema: type: string - description: Unique ID of the booking. responses: "200": description: "" @@ -1401,7 +1395,6 @@ paths: required: true schema: type: string - description: Unique ID of the booking. responses: "200": description: "" @@ -1449,7 +1442,6 @@ paths: description: List jobs with these tags. schema: type: array - description: List jobs with these tags. items: type: string - in: query @@ -1457,21 +1449,18 @@ paths: description: Page number. schema: type: integer - description: Page number. format: int32 - in: query name: page_size description: Maximum number of jobs to return per page. schema: type: integer - description: Maximum number of jobs to return per page. format: uint32 - in: query name: order_by description: Sort order of the returned jobs. schema: type: string - description: Sort order of the returned jobs. enum: - created_at_desc - created_at_asc @@ -1619,7 +1608,6 @@ paths: required: true schema: type: string - description: Unique ID of the job you want to get. responses: "200": description: "" @@ -1652,7 +1640,6 @@ paths: required: true schema: type: string - description: Unique ID of the job. responses: "200": description: "" @@ -1707,7 +1694,6 @@ paths: required: true schema: type: string - description: Unique ID of the job. responses: "204": description: "" @@ -1737,7 +1723,6 @@ paths: required: true schema: type: string - description: Unique ID of the job. responses: "200": description: "" @@ -1779,7 +1764,6 @@ paths: required: true schema: type: string - description: Unique ID of the job. responses: "200": description: "" @@ -1813,27 +1797,23 @@ paths: required: true schema: type: string - description: ID of the job. - in: query name: page description: Page number. schema: type: integer - description: Page number. format: int32 - in: query name: page_size description: Maximum number of results to return per page. schema: type: integer - description: Maximum number of results to return per page. format: uint32 - in: query name: order_by description: Sort order of the returned results. schema: type: string - description: Sort order of the returned results. enum: - created_at_desc - created_at_asc @@ -1872,27 +1852,23 @@ paths: required: true schema: type: string - description: List models belonging to this project ID. - in: query name: page description: Page number. schema: type: integer - description: Page number. format: int32 - in: query name: page_size description: Maximum number of results to return per page. schema: type: integer - description: Maximum number of results to return per page. format: uint32 - in: query name: order_by description: Sort order of the returned results. schema: type: string - description: Sort order of the returned results. enum: - created_at_desc - created_at_asc @@ -1977,7 +1953,6 @@ paths: required: true schema: type: string - description: Unique ID of the model. responses: "200": description: "" @@ -2010,25 +1985,21 @@ paths: description: List platforms with this provider name. schema: type: string - description: List platforms with this provider name. - in: query name: backend_name description: List platforms with this backend name. schema: type: string - description: List platforms with this backend name. - in: query name: name description: List platforms with this name. schema: type: string - description: List platforms with this name. - in: query name: platform_type description: List platforms with this type. schema: type: string - description: List platforms with this type. enum: - unknown_type - simulator @@ -2039,7 +2010,6 @@ paths: description: List platforms with this technology. schema: type: string - description: List platforms with this technology. enum: - unknown_technology - photonic @@ -2053,21 +2023,18 @@ paths: description: Page number. schema: type: integer - description: Page number. format: int32 - in: query name: page_size description: Maximum number of platforms to return per page. schema: type: integer - description: Maximum number of platforms to return per page. format: uint32 - in: query name: order_by description: Sort order of the returned platforms. schema: type: string - description: Sort order of the returned platforms. enum: - name_asc - name_desc @@ -2114,7 +2081,6 @@ paths: required: true schema: type: string - description: Unique ID of the platform. responses: "200": description: "" @@ -2147,13 +2113,11 @@ paths: description: List processes that have been created for this application. schema: type: string - description: List processes that have been created for this application. - in: query name: tags description: List processes with these tags. schema: type: array - description: List processes with these tags. items: type: string - in: query @@ -2161,21 +2125,18 @@ paths: description: Page number. schema: type: integer - description: Page number. format: int32 - in: query name: page_size description: Maximum number of processes to return per page. schema: type: integer - description: Maximum number of processes to return per page. format: uint32 - in: query name: order_by description: Sort order of the returned processes. schema: type: string - description: Sort order of the returned processes. enum: - created_at_desc - created_at_asc @@ -2192,7 +2153,6 @@ paths: required: true schema: type: string - description: List processes belonging to this project ID. (UUID format) example: 6170692e-7363-616c-6577-61792e636f6d responses: "200": @@ -2309,7 +2269,6 @@ paths: required: true schema: type: string - description: Unique ID of the process. responses: "200": description: "" @@ -2342,7 +2301,6 @@ paths: required: true schema: type: string - description: Unique ID of the process. responses: "200": description: "" @@ -2397,7 +2355,6 @@ paths: required: true schema: type: string - description: Unique ID of the process. responses: "204": description: "" @@ -2428,7 +2385,6 @@ paths: required: true schema: type: string - description: Unique ID of the process. responses: "200": description: "" @@ -2470,27 +2426,23 @@ paths: required: true schema: type: string - description: ID of the process. - in: query name: page description: Page number. schema: type: integer - description: Page number. format: int32 - in: query name: page_size description: Maximum number of results to return per page. schema: type: integer - description: Maximum number of results to return per page. format: uint32 - in: query name: order_by description: Sort order of the returned results. schema: type: string - description: Sort order of the returned results. enum: - created_at_desc - created_at_asc @@ -2527,13 +2479,11 @@ paths: description: List sessions that have been created for this platform. schema: type: string - description: List sessions that have been created for this platform. - in: query name: tags description: List sessions with these tags. schema: type: array - description: List sessions with these tags. items: type: string - in: query @@ -2541,21 +2491,18 @@ paths: description: Page number. schema: type: integer - description: Page number. format: int32 - in: query name: page_size description: Maximum number of sessions to return per page. schema: type: integer - description: Maximum number of sessions to return per page. format: uint32 - in: query name: order_by description: Sort order of the returned sessions. schema: type: string - description: Sort order of the returned sessions. enum: - name_asc - name_desc @@ -2572,7 +2519,6 @@ paths: required: true schema: type: string - description: List sessions belonging to this project ID. (UUID format) example: 6170692e-7363-616c-6577-61792e636f6d responses: "200": @@ -2666,10 +2612,13 @@ paths: nullable: true description: $ref: '#/components/schemas/google.protobuf.StringValue' + time_zone: + $ref: '#/components/schemas/google.protobuf.StringValue' x-properties-order: - started_at - finished_at - description + - time_zone model_id: type: string description: Default computation model ID to be executed by job @@ -2725,7 +2674,6 @@ paths: required: true schema: type: string - description: Unique ID of the session. responses: "200": description: "" @@ -2758,7 +2706,6 @@ paths: required: true schema: type: string - description: Unique ID of the session. responses: "200": description: "" @@ -2827,7 +2774,6 @@ paths: required: true schema: type: string - description: Unique ID of the session. responses: "204": description: "" @@ -2899,7 +2845,6 @@ paths: required: true schema: type: string - description: Unique ID of the session. responses: "200": description: "" diff --git a/requirements.txt b/requirements.txt index 35ef2e0..8b79b3a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,6 @@ randomname>=0.2.1 httpx>=0.27.0 pytimeparse>=1.1.8 attrs>=22.2.0 -python-dateutil>=2.8.0 \ No newline at end of file +python-dateutil>=2.8.0 +pytz>=2024.1 +tzlocal>=5.3.1 \ No newline at end of file diff --git a/scaleway_qaas_client/v1alpha1/__init__.py b/scaleway_qaas_client/v1alpha1/__init__.py index 0bd96f5..394ebe0 100644 --- a/scaleway_qaas_client/v1alpha1/__init__.py +++ b/scaleway_qaas_client/v1alpha1/__init__.py @@ -25,6 +25,9 @@ from .quantum_as_a_service_api_client.models import ( ScalewayQaasV1Alpha1Application as QaaSApplication, ) +from .quantum_as_a_service_api_client.models import ( + ScalewayQaasV1Alpha1Booking as QaaSBooking, +) from .quantum_as_a_service_api_client.models import ScalewayQaasV1Alpha1Job as QaaSJob from .quantum_as_a_service_api_client.models import ( ScalewayQaasV1Alpha1JobResult as QaaSJobResult, @@ -44,6 +47,9 @@ from .quantum_as_a_service_api_client.models import ( ScalewayQaasV1Alpha1PlatformAvailability as QaaSPlatformAvailability, ) +from .quantum_as_a_service_api_client.models import ( + ScalewayQaasV1Alpha1PlatformBookingRequirement as QaaSBookingRequirements, +) from .quantum_as_a_service_api_client.models import ( ScalewayQaasV1Alpha1PlatformTechnology as QaaSPlatformTechnology, ) @@ -65,9 +71,3 @@ from .quantum_as_a_service_api_client.models import ( ScalewayQaasV1Alpha1SessionStatus as QaaSSessionStatus, ) -from .quantum_as_a_service_api_client.models import ( - ScalewayQaasV1Alpha1PlatformBookingRequirement as QaaSBookingRequirements, -) -from .quantum_as_a_service_api_client.models import ( - ScalewayQaasV1Alpha1Booking as QaaSBooking, -) diff --git a/scaleway_qaas_client/v1alpha1/client.py b/scaleway_qaas_client/v1alpha1/client.py index 95974ee..0c0fc13 100644 --- a/scaleway_qaas_client/v1alpha1/client.py +++ b/scaleway_qaas_client/v1alpha1/client.py @@ -127,6 +127,8 @@ Response, ) +from scaleway_qaas_client.v1alpha1.utils import get_local_iana_timezone, is_valid_iana + _DEFAULT_URL = "https://api.scaleway.com" @@ -251,6 +253,7 @@ def create_session( booking_demand_started_at: Optional[datetime] = None, booking_demand_finished_at: Optional[datetime] = None, booking_demand_description: Optional[str] = None, + booking_demand_time_zone: Optional[str] = None, ) -> ScalewayQaasV1Alpha1Session: """Create a session @@ -267,6 +270,7 @@ def create_session( booking_demand_started_at (Union[None, Unset, datetime.datetime]): Wished started time for an exclusive session over a QPU, only works if the platform is_bookable (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z. booking_demand_finished_at (Union[None, Unset, datetime.datetime]): Wished finished time for an exclusive session over a QPU, only works if the platform is_bookable (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z. booking_demand_description (Union[None, Unset, str]): User description of the booking + booking_demand_time_zone (Union[None, Unset, str]): Time zone of the demanded booking (eg: Europe/Paris, America/New_York...) Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -309,13 +313,21 @@ def create_session( booking_demand_finished_at_timestamp = ( booking_demand_finished_at.timestamp() ) - # seconds = int(booking_demand_started_at_timestamp) - # nanos = int(booking_demand_started_at_timestamp % 1 * 1e9) + + if booking_demand_time_zone is not None and not is_valid_iana( + booking_demand_time_zone + ): + raise Exception( + f"create_session: invalid time zone {booking_demand_time_zone} as IANA format" + ) + else: + time_zone = get_local_iana_timezone() booking_demand = CreateSessionBodyBookingDemand( started_at=booking_demand_started_at_timestamp, finished_at=booking_demand_finished_at_timestamp, description=booking_demand_description, + time_zone=time_zone, ) response = _create_session_sync( diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/applications/get_application.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/applications/get_application.py index f18938d..a7730dc 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/applications/get_application.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/applications/get_application.py @@ -57,7 +57,7 @@ def sync_detailed( platforms. Args: - application_id (str): Unique ID of the application. + application_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -89,7 +89,7 @@ def sync( platforms. Args: - application_id (str): Unique ID of the application. + application_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -116,7 +116,7 @@ async def asyncio_detailed( platforms. Args: - application_id (str): Unique ID of the application. + application_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -146,7 +146,7 @@ async def asyncio( platforms. Args: - application_id (str): Unique ID of the application. + application_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/applications/list_applications.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/applications/list_applications.py index f62756c..d03e18f 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/applications/list_applications.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/applications/list_applications.py @@ -96,13 +96,13 @@ def sync_detailed( Retrieve information about all applications. Args: - name (Union[Unset, str]): List applications with this name. - application_type (Union[Unset, ListApplicationsApplicationType]): List applications with - this type. Default: ListApplicationsApplicationType.UNKNOWN_TYPE. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of applications a to return per page. - order_by (Union[Unset, ListApplicationsOrderBy]): Sort order of the returned applications. - Default: ListApplicationsOrderBy.NAME_ASC. + name (Union[Unset, str]): + application_type (Union[Unset, ListApplicationsApplicationType]): Default: + ListApplicationsApplicationType.UNKNOWN_TYPE. + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListApplicationsOrderBy]): Default: + ListApplicationsOrderBy.NAME_ASC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -143,13 +143,13 @@ def sync( Retrieve information about all applications. Args: - name (Union[Unset, str]): List applications with this name. - application_type (Union[Unset, ListApplicationsApplicationType]): List applications with - this type. Default: ListApplicationsApplicationType.UNKNOWN_TYPE. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of applications a to return per page. - order_by (Union[Unset, ListApplicationsOrderBy]): Sort order of the returned applications. - Default: ListApplicationsOrderBy.NAME_ASC. + name (Union[Unset, str]): + application_type (Union[Unset, ListApplicationsApplicationType]): Default: + ListApplicationsApplicationType.UNKNOWN_TYPE. + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListApplicationsOrderBy]): Default: + ListApplicationsOrderBy.NAME_ASC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -185,13 +185,13 @@ async def asyncio_detailed( Retrieve information about all applications. Args: - name (Union[Unset, str]): List applications with this name. - application_type (Union[Unset, ListApplicationsApplicationType]): List applications with - this type. Default: ListApplicationsApplicationType.UNKNOWN_TYPE. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of applications a to return per page. - order_by (Union[Unset, ListApplicationsOrderBy]): Sort order of the returned applications. - Default: ListApplicationsOrderBy.NAME_ASC. + name (Union[Unset, str]): + application_type (Union[Unset, ListApplicationsApplicationType]): Default: + ListApplicationsApplicationType.UNKNOWN_TYPE. + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListApplicationsOrderBy]): Default: + ListApplicationsOrderBy.NAME_ASC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -230,13 +230,13 @@ async def asyncio( Retrieve information about all applications. Args: - name (Union[Unset, str]): List applications with this name. - application_type (Union[Unset, ListApplicationsApplicationType]): List applications with - this type. Default: ListApplicationsApplicationType.UNKNOWN_TYPE. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of applications a to return per page. - order_by (Union[Unset, ListApplicationsOrderBy]): Sort order of the returned applications. - Default: ListApplicationsOrderBy.NAME_ASC. + name (Union[Unset, str]): + application_type (Union[Unset, ListApplicationsApplicationType]): Default: + ListApplicationsApplicationType.UNKNOWN_TYPE. + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListApplicationsOrderBy]): Default: + ListApplicationsOrderBy.NAME_ASC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/get_booking.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/get_booking.py index e38e9b5..260c8cc 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/get_booking.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/get_booking.py @@ -55,7 +55,7 @@ def sync_detailed( message. Args: - booking_id (str): Unique ID of the booking. + booking_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -87,7 +87,7 @@ def sync( message. Args: - booking_id (str): Unique ID of the booking. + booking_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -114,7 +114,7 @@ async def asyncio_detailed( message. Args: - booking_id (str): Unique ID of the booking. + booking_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -144,7 +144,7 @@ async def asyncio( message. Args: - booking_id (str): Unique ID of the booking. + booking_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/list_bookings.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/list_bookings.py index e16e531..037c031 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/list_bookings.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/list_bookings.py @@ -87,12 +87,11 @@ def sync_detailed( Retrieve information about all bookings of the provided **project ID** or ** platform ID**. Args: - project_id (Union[Unset, str]): List bookings belonging to this project ID. (UUID format) - Example: 6170692e-7363-616c-6577-61792e636f6d. - platform_id (Union[Unset, str]): List bookings attached to this platform ID. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListBookingsOrderBy]): Sort order of the returned results. Default: + project_id (Union[Unset, str]): Example: 6170692e-7363-616c-6577-61792e636f6d. + platform_id (Union[Unset, str]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListBookingsOrderBy]): Default: ListBookingsOrderBy.CREATED_AT_DESC. Raises: @@ -132,12 +131,11 @@ def sync( Retrieve information about all bookings of the provided **project ID** or ** platform ID**. Args: - project_id (Union[Unset, str]): List bookings belonging to this project ID. (UUID format) - Example: 6170692e-7363-616c-6577-61792e636f6d. - platform_id (Union[Unset, str]): List bookings attached to this platform ID. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListBookingsOrderBy]): Sort order of the returned results. Default: + project_id (Union[Unset, str]): Example: 6170692e-7363-616c-6577-61792e636f6d. + platform_id (Union[Unset, str]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListBookingsOrderBy]): Default: ListBookingsOrderBy.CREATED_AT_DESC. Raises: @@ -172,12 +170,11 @@ async def asyncio_detailed( Retrieve information about all bookings of the provided **project ID** or ** platform ID**. Args: - project_id (Union[Unset, str]): List bookings belonging to this project ID. (UUID format) - Example: 6170692e-7363-616c-6577-61792e636f6d. - platform_id (Union[Unset, str]): List bookings attached to this platform ID. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListBookingsOrderBy]): Sort order of the returned results. Default: + project_id (Union[Unset, str]): Example: 6170692e-7363-616c-6577-61792e636f6d. + platform_id (Union[Unset, str]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListBookingsOrderBy]): Default: ListBookingsOrderBy.CREATED_AT_DESC. Raises: @@ -215,12 +212,11 @@ async def asyncio( Retrieve information about all bookings of the provided **project ID** or ** platform ID**. Args: - project_id (Union[Unset, str]): List bookings belonging to this project ID. (UUID format) - Example: 6170692e-7363-616c-6577-61792e636f6d. - platform_id (Union[Unset, str]): List bookings attached to this platform ID. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListBookingsOrderBy]): Sort order of the returned results. Default: + project_id (Union[Unset, str]): Example: 6170692e-7363-616c-6577-61792e636f6d. + platform_id (Union[Unset, str]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListBookingsOrderBy]): Default: ListBookingsOrderBy.CREATED_AT_DESC. Raises: diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/update_booking.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/update_booking.py index 1f04aad..25ceeca 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/update_booking.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/bookings/update_booking.py @@ -65,7 +65,7 @@ def sync_detailed( Update booking information of the provided **booking ID**. Args: - booking_id (str): Unique ID of the booking. + booking_id (str): body (UpdateBookingBody): Raises: @@ -99,7 +99,7 @@ def sync( Update booking information of the provided **booking ID**. Args: - booking_id (str): Unique ID of the booking. + booking_id (str): body (UpdateBookingBody): Raises: @@ -128,7 +128,7 @@ async def asyncio_detailed( Update booking information of the provided **booking ID**. Args: - booking_id (str): Unique ID of the booking. + booking_id (str): body (UpdateBookingBody): Raises: @@ -160,7 +160,7 @@ async def asyncio( Update booking information of the provided **booking ID**. Args: - booking_id (str): Unique ID of the booking. + booking_id (str): body (UpdateBookingBody): Raises: diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/cancel_job.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/cancel_job.py index eecadb2..c8d13f1 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/cancel_job.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/cancel_job.py @@ -65,7 +65,7 @@ def sync_detailed( Cancel the job corresponding to the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): body (CancelJobBody): Raises: @@ -99,7 +99,7 @@ def sync( Cancel the job corresponding to the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): body (CancelJobBody): Raises: @@ -128,7 +128,7 @@ async def asyncio_detailed( Cancel the job corresponding to the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): body (CancelJobBody): Raises: @@ -160,7 +160,7 @@ async def asyncio( Cancel the job corresponding to the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): body (CancelJobBody): Raises: diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/delete_job.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/delete_job.py index f97214e..83b9bf9 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/delete_job.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/delete_job.py @@ -51,7 +51,7 @@ def sync_detailed( Delete the job corresponding to the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -82,7 +82,7 @@ async def asyncio_detailed( Delete the job corresponding to the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/get_job.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/get_job.py index 236ac1e..17f799c 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/get_job.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/get_job.py @@ -54,7 +54,7 @@ def sync_detailed( Retrieve information about the provided **job ID**, such as status, payload, and result. Args: - job_id (str): Unique ID of the job you want to get. + job_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -85,7 +85,7 @@ def sync( Retrieve information about the provided **job ID**, such as status, payload, and result. Args: - job_id (str): Unique ID of the job you want to get. + job_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -111,7 +111,7 @@ async def asyncio_detailed( Retrieve information about the provided **job ID**, such as status, payload, and result. Args: - job_id (str): Unique ID of the job you want to get. + job_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -140,7 +140,7 @@ async def asyncio( Retrieve information about the provided **job ID**, such as status, payload, and result. Args: - job_id (str): Unique ID of the job you want to get. + job_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/get_job_circuit.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/get_job_circuit.py index b6bc989..4372891 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/get_job_circuit.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/get_job_circuit.py @@ -56,7 +56,7 @@ def sync_detailed( Retrieve the circuit of the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -87,7 +87,7 @@ def sync( Retrieve the circuit of the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -113,7 +113,7 @@ async def asyncio_detailed( Retrieve the circuit of the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -142,7 +142,7 @@ async def asyncio( Retrieve the circuit of the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/list_job_results.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/list_job_results.py index 47f72b6..ac33091 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/list_job_results.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/list_job_results.py @@ -85,11 +85,11 @@ def sync_detailed( Retrieve all intermediate and final results of a job. Args: - job_id (str): ID of the job. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListJobResultsOrderBy]): Sort order of the returned results. - Default: ListJobResultsOrderBy.CREATED_AT_DESC. + job_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListJobResultsOrderBy]): Default: + ListJobResultsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -128,11 +128,11 @@ def sync( Retrieve all intermediate and final results of a job. Args: - job_id (str): ID of the job. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListJobResultsOrderBy]): Sort order of the returned results. - Default: ListJobResultsOrderBy.CREATED_AT_DESC. + job_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListJobResultsOrderBy]): Default: + ListJobResultsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -166,11 +166,11 @@ async def asyncio_detailed( Retrieve all intermediate and final results of a job. Args: - job_id (str): ID of the job. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListJobResultsOrderBy]): Sort order of the returned results. - Default: ListJobResultsOrderBy.CREATED_AT_DESC. + job_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListJobResultsOrderBy]): Default: + ListJobResultsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -207,11 +207,11 @@ async def asyncio( Retrieve all intermediate and final results of a job. Args: - job_id (str): ID of the job. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListJobResultsOrderBy]): Sort order of the returned results. - Default: ListJobResultsOrderBy.CREATED_AT_DESC. + job_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListJobResultsOrderBy]): Default: + ListJobResultsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/update_job.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/update_job.py index 4cc995a..27a3b97 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/update_job.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/jobs/update_job.py @@ -65,7 +65,7 @@ def sync_detailed( Update job information about the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): body (UpdateJobBody): Raises: @@ -99,7 +99,7 @@ def sync( Update job information about the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): body (UpdateJobBody): Raises: @@ -128,7 +128,7 @@ async def asyncio_detailed( Update job information about the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): body (UpdateJobBody): Raises: @@ -160,7 +160,7 @@ async def asyncio( Update job information about the provided **job ID**. Args: - job_id (str): Unique ID of the job. + job_id (str): body (UpdateJobBody): Raises: diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/models/get_model.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/models/get_model.py index d8eaee0..453ea38 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/models/get_model.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/models/get_model.py @@ -54,7 +54,7 @@ def sync_detailed( Retrieve information about of the provided **model ID**. Args: - model_id (str): Unique ID of the model. + model_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -85,7 +85,7 @@ def sync( Retrieve information about of the provided **model ID**. Args: - model_id (str): Unique ID of the model. + model_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -111,7 +111,7 @@ async def asyncio_detailed( Retrieve information about of the provided **model ID**. Args: - model_id (str): Unique ID of the model. + model_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -140,7 +140,7 @@ async def asyncio( Retrieve information about of the provided **model ID**. Args: - model_id (str): Unique ID of the model. + model_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/models/list_models.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/models/list_models.py index 5bf9465..94c73ea 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/models/list_models.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/models/list_models.py @@ -81,11 +81,10 @@ def sync_detailed( Retrieve information about all models of the provided **project ID**. Args: - project_id (str): List models belonging to this project ID. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListModelsOrderBy]): Sort order of the returned results. Default: - ListModelsOrderBy.CREATED_AT_DESC. + project_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListModelsOrderBy]): Default: ListModelsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -122,11 +121,10 @@ def sync( Retrieve information about all models of the provided **project ID**. Args: - project_id (str): List models belonging to this project ID. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListModelsOrderBy]): Sort order of the returned results. Default: - ListModelsOrderBy.CREATED_AT_DESC. + project_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListModelsOrderBy]): Default: ListModelsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -158,11 +156,10 @@ async def asyncio_detailed( Retrieve information about all models of the provided **project ID**. Args: - project_id (str): List models belonging to this project ID. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListModelsOrderBy]): Sort order of the returned results. Default: - ListModelsOrderBy.CREATED_AT_DESC. + project_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListModelsOrderBy]): Default: ListModelsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -197,11 +194,10 @@ async def asyncio( Retrieve information about all models of the provided **project ID**. Args: - project_id (str): List models belonging to this project ID. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListModelsOrderBy]): Sort order of the returned results. Default: - ListModelsOrderBy.CREATED_AT_DESC. + project_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListModelsOrderBy]): Default: ListModelsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/platforms/get_platform.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/platforms/get_platform.py index 693ed41..ed8d908 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/platforms/get_platform.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/platforms/get_platform.py @@ -55,7 +55,7 @@ def sync_detailed( type. Args: - platform_id (str): Unique ID of the platform. + platform_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -87,7 +87,7 @@ def sync( type. Args: - platform_id (str): Unique ID of the platform. + platform_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -114,7 +114,7 @@ async def asyncio_detailed( type. Args: - platform_id (str): Unique ID of the platform. + platform_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -144,7 +144,7 @@ async def asyncio( type. Args: - platform_id (str): Unique ID of the platform. + platform_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/platforms/list_platforms.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/platforms/list_platforms.py index 04e2b7a..4716e2f 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/platforms/list_platforms.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/platforms/list_platforms.py @@ -117,17 +117,16 @@ def sync_detailed( Retrieve information about all platforms. Args: - provider_name (Union[Unset, str]): List platforms with this provider name. - backend_name (Union[Unset, str]): List platforms with this backend name. - name (Union[Unset, str]): List platforms with this name. - platform_type (Union[Unset, ListPlatformsPlatformType]): List platforms with this type. - Default: ListPlatformsPlatformType.UNKNOWN_TYPE. - platform_technology (Union[Unset, ListPlatformsPlatformTechnology]): List platforms with - this technology. Default: ListPlatformsPlatformTechnology.UNKNOWN_TECHNOLOGY. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of platforms to return per page. - order_by (Union[Unset, ListPlatformsOrderBy]): Sort order of the returned platforms. - Default: ListPlatformsOrderBy.NAME_ASC. + provider_name (Union[Unset, str]): + backend_name (Union[Unset, str]): + name (Union[Unset, str]): + platform_type (Union[Unset, ListPlatformsPlatformType]): Default: + ListPlatformsPlatformType.UNKNOWN_TYPE. + platform_technology (Union[Unset, ListPlatformsPlatformTechnology]): Default: + ListPlatformsPlatformTechnology.UNKNOWN_TECHNOLOGY. + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListPlatformsOrderBy]): Default: ListPlatformsOrderBy.NAME_ASC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -176,17 +175,16 @@ def sync( Retrieve information about all platforms. Args: - provider_name (Union[Unset, str]): List platforms with this provider name. - backend_name (Union[Unset, str]): List platforms with this backend name. - name (Union[Unset, str]): List platforms with this name. - platform_type (Union[Unset, ListPlatformsPlatformType]): List platforms with this type. - Default: ListPlatformsPlatformType.UNKNOWN_TYPE. - platform_technology (Union[Unset, ListPlatformsPlatformTechnology]): List platforms with - this technology. Default: ListPlatformsPlatformTechnology.UNKNOWN_TECHNOLOGY. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of platforms to return per page. - order_by (Union[Unset, ListPlatformsOrderBy]): Sort order of the returned platforms. - Default: ListPlatformsOrderBy.NAME_ASC. + provider_name (Union[Unset, str]): + backend_name (Union[Unset, str]): + name (Union[Unset, str]): + platform_type (Union[Unset, ListPlatformsPlatformType]): Default: + ListPlatformsPlatformType.UNKNOWN_TYPE. + platform_technology (Union[Unset, ListPlatformsPlatformTechnology]): Default: + ListPlatformsPlatformTechnology.UNKNOWN_TECHNOLOGY. + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListPlatformsOrderBy]): Default: ListPlatformsOrderBy.NAME_ASC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -230,17 +228,16 @@ async def asyncio_detailed( Retrieve information about all platforms. Args: - provider_name (Union[Unset, str]): List platforms with this provider name. - backend_name (Union[Unset, str]): List platforms with this backend name. - name (Union[Unset, str]): List platforms with this name. - platform_type (Union[Unset, ListPlatformsPlatformType]): List platforms with this type. - Default: ListPlatformsPlatformType.UNKNOWN_TYPE. - platform_technology (Union[Unset, ListPlatformsPlatformTechnology]): List platforms with - this technology. Default: ListPlatformsPlatformTechnology.UNKNOWN_TECHNOLOGY. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of platforms to return per page. - order_by (Union[Unset, ListPlatformsOrderBy]): Sort order of the returned platforms. - Default: ListPlatformsOrderBy.NAME_ASC. + provider_name (Union[Unset, str]): + backend_name (Union[Unset, str]): + name (Union[Unset, str]): + platform_type (Union[Unset, ListPlatformsPlatformType]): Default: + ListPlatformsPlatformType.UNKNOWN_TYPE. + platform_technology (Union[Unset, ListPlatformsPlatformTechnology]): Default: + ListPlatformsPlatformTechnology.UNKNOWN_TECHNOLOGY. + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListPlatformsOrderBy]): Default: ListPlatformsOrderBy.NAME_ASC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -287,17 +284,16 @@ async def asyncio( Retrieve information about all platforms. Args: - provider_name (Union[Unset, str]): List platforms with this provider name. - backend_name (Union[Unset, str]): List platforms with this backend name. - name (Union[Unset, str]): List platforms with this name. - platform_type (Union[Unset, ListPlatformsPlatformType]): List platforms with this type. - Default: ListPlatformsPlatformType.UNKNOWN_TYPE. - platform_technology (Union[Unset, ListPlatformsPlatformTechnology]): List platforms with - this technology. Default: ListPlatformsPlatformTechnology.UNKNOWN_TECHNOLOGY. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of platforms to return per page. - order_by (Union[Unset, ListPlatformsOrderBy]): Sort order of the returned platforms. - Default: ListPlatformsOrderBy.NAME_ASC. + provider_name (Union[Unset, str]): + backend_name (Union[Unset, str]): + name (Union[Unset, str]): + platform_type (Union[Unset, ListPlatformsPlatformType]): Default: + ListPlatformsPlatformType.UNKNOWN_TYPE. + platform_technology (Union[Unset, ListPlatformsPlatformTechnology]): Default: + ListPlatformsPlatformTechnology.UNKNOWN_TECHNOLOGY. + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListPlatformsOrderBy]): Default: ListPlatformsOrderBy.NAME_ASC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/cancel_process.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/cancel_process.py index 43d516a..2922f20 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/cancel_process.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/cancel_process.py @@ -65,7 +65,7 @@ def sync_detailed( Cancel a process by its unique ID. Intermediate results are still available. Args: - process_id (str): Unique ID of the process. + process_id (str): body (CancelProcessBody): Raises: @@ -99,7 +99,7 @@ def sync( Cancel a process by its unique ID. Intermediate results are still available. Args: - process_id (str): Unique ID of the process. + process_id (str): body (CancelProcessBody): Raises: @@ -128,7 +128,7 @@ async def asyncio_detailed( Cancel a process by its unique ID. Intermediate results are still available. Args: - process_id (str): Unique ID of the process. + process_id (str): body (CancelProcessBody): Raises: @@ -160,7 +160,7 @@ async def asyncio( Cancel a process by its unique ID. Intermediate results are still available. Args: - process_id (str): Unique ID of the process. + process_id (str): body (CancelProcessBody): Raises: diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/delete_process.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/delete_process.py index f9a5bf1..e1ecf3e 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/delete_process.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/delete_process.py @@ -51,7 +51,7 @@ def sync_detailed( Delete a process by its unique ID and delete all its data. Args: - process_id (str): Unique ID of the process. + process_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -82,7 +82,7 @@ async def asyncio_detailed( Delete a process by its unique ID and delete all its data. Args: - process_id (str): Unique ID of the process. + process_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/get_process.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/get_process.py index e8c2855..de610cd 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/get_process.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/get_process.py @@ -54,7 +54,7 @@ def sync_detailed( Retrieve information about the provided **process ID**, such as name, status and progress. Args: - process_id (str): Unique ID of the process. + process_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -85,7 +85,7 @@ def sync( Retrieve information about the provided **process ID**, such as name, status and progress. Args: - process_id (str): Unique ID of the process. + process_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -111,7 +111,7 @@ async def asyncio_detailed( Retrieve information about the provided **process ID**, such as name, status and progress. Args: - process_id (str): Unique ID of the process. + process_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -140,7 +140,7 @@ async def asyncio( Retrieve information about the provided **process ID**, such as name, status and progress. Args: - process_id (str): Unique ID of the process. + process_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/list_process_results.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/list_process_results.py index 2d0d8bb..a1073a2 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/list_process_results.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/list_process_results.py @@ -85,11 +85,11 @@ def sync_detailed( Retrieve all intermediate and final result of a process. Args: - process_id (str): ID of the process. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListProcessResultsOrderBy]): Sort order of the returned results. - Default: ListProcessResultsOrderBy.CREATED_AT_DESC. + process_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListProcessResultsOrderBy]): Default: + ListProcessResultsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -128,11 +128,11 @@ def sync( Retrieve all intermediate and final result of a process. Args: - process_id (str): ID of the process. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListProcessResultsOrderBy]): Sort order of the returned results. - Default: ListProcessResultsOrderBy.CREATED_AT_DESC. + process_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListProcessResultsOrderBy]): Default: + ListProcessResultsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -166,11 +166,11 @@ async def asyncio_detailed( Retrieve all intermediate and final result of a process. Args: - process_id (str): ID of the process. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListProcessResultsOrderBy]): Sort order of the returned results. - Default: ListProcessResultsOrderBy.CREATED_AT_DESC. + process_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListProcessResultsOrderBy]): Default: + ListProcessResultsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -207,11 +207,11 @@ async def asyncio( Retrieve all intermediate and final result of a process. Args: - process_id (str): ID of the process. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of results to return per page. - order_by (Union[Unset, ListProcessResultsOrderBy]): Sort order of the returned results. - Default: ListProcessResultsOrderBy.CREATED_AT_DESC. + process_id (str): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListProcessResultsOrderBy]): Default: + ListProcessResultsOrderBy.CREATED_AT_DESC. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/list_processes.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/list_processes.py index 34d3195..e14e970 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/list_processes.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/list_processes.py @@ -95,15 +95,13 @@ def sync_detailed( Retrieve information about all processes. Args: - application_id (Union[Unset, str]): List processes that have been created for this - application. - tags (Union[Unset, list[str]]): List processes with these tags. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of processes to return per page. - order_by (Union[Unset, ListProcessesOrderBy]): Sort order of the returned processes. - Default: ListProcessesOrderBy.CREATED_AT_DESC. - project_id (str): List processes belonging to this project ID. (UUID format) Example: - 6170692e-7363-616c-6577-61792e636f6d. + application_id (Union[Unset, str]): + tags (Union[Unset, list[str]]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListProcessesOrderBy]): Default: + ListProcessesOrderBy.CREATED_AT_DESC. + project_id (str): Example: 6170692e-7363-616c-6577-61792e636f6d. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -144,15 +142,13 @@ def sync( Retrieve information about all processes. Args: - application_id (Union[Unset, str]): List processes that have been created for this - application. - tags (Union[Unset, list[str]]): List processes with these tags. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of processes to return per page. - order_by (Union[Unset, ListProcessesOrderBy]): Sort order of the returned processes. - Default: ListProcessesOrderBy.CREATED_AT_DESC. - project_id (str): List processes belonging to this project ID. (UUID format) Example: - 6170692e-7363-616c-6577-61792e636f6d. + application_id (Union[Unset, str]): + tags (Union[Unset, list[str]]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListProcessesOrderBy]): Default: + ListProcessesOrderBy.CREATED_AT_DESC. + project_id (str): Example: 6170692e-7363-616c-6577-61792e636f6d. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -188,15 +184,13 @@ async def asyncio_detailed( Retrieve information about all processes. Args: - application_id (Union[Unset, str]): List processes that have been created for this - application. - tags (Union[Unset, list[str]]): List processes with these tags. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of processes to return per page. - order_by (Union[Unset, ListProcessesOrderBy]): Sort order of the returned processes. - Default: ListProcessesOrderBy.CREATED_AT_DESC. - project_id (str): List processes belonging to this project ID. (UUID format) Example: - 6170692e-7363-616c-6577-61792e636f6d. + application_id (Union[Unset, str]): + tags (Union[Unset, list[str]]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListProcessesOrderBy]): Default: + ListProcessesOrderBy.CREATED_AT_DESC. + project_id (str): Example: 6170692e-7363-616c-6577-61792e636f6d. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -235,15 +229,13 @@ async def asyncio( Retrieve information about all processes. Args: - application_id (Union[Unset, str]): List processes that have been created for this - application. - tags (Union[Unset, list[str]]): List processes with these tags. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of processes to return per page. - order_by (Union[Unset, ListProcessesOrderBy]): Sort order of the returned processes. - Default: ListProcessesOrderBy.CREATED_AT_DESC. - project_id (str): List processes belonging to this project ID. (UUID format) Example: - 6170692e-7363-616c-6577-61792e636f6d. + application_id (Union[Unset, str]): + tags (Union[Unset, list[str]]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListProcessesOrderBy]): Default: + ListProcessesOrderBy.CREATED_AT_DESC. + project_id (str): Example: 6170692e-7363-616c-6577-61792e636f6d. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/update_process.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/update_process.py index 0b96e92..75fa387 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/update_process.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/processes/update_process.py @@ -65,7 +65,7 @@ def sync_detailed( Update process information of the provided **process ID**. Args: - process_id (str): Unique ID of the process. + process_id (str): body (UpdateProcessBody): Raises: @@ -99,7 +99,7 @@ def sync( Update process information of the provided **process ID**. Args: - process_id (str): Unique ID of the process. + process_id (str): body (UpdateProcessBody): Raises: @@ -128,7 +128,7 @@ async def asyncio_detailed( Update process information of the provided **process ID**. Args: - process_id (str): Unique ID of the process. + process_id (str): body (UpdateProcessBody): Raises: @@ -160,7 +160,7 @@ async def asyncio( Update process information of the provided **process ID**. Args: - process_id (str): Unique ID of the process. + process_id (str): body (UpdateProcessBody): Raises: diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/delete_session.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/delete_session.py index ab481bc..ef5b445 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/delete_session.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/delete_session.py @@ -51,7 +51,7 @@ def sync_detailed( Delete a session by its unique ID and delete all its attached job and booking. Args: - session_id (str): Unique ID of the session. + session_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -82,7 +82,7 @@ async def asyncio_detailed( Delete a session by its unique ID and delete all its attached job and booking. Args: - session_id (str): Unique ID of the session. + session_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/get_session.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/get_session.py index 0843f70..37d079b 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/get_session.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/get_session.py @@ -55,7 +55,7 @@ def sync_detailed( jobs. Args: - session_id (str): Unique ID of the session. + session_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -87,7 +87,7 @@ def sync( jobs. Args: - session_id (str): Unique ID of the session. + session_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -114,7 +114,7 @@ async def asyncio_detailed( jobs. Args: - session_id (str): Unique ID of the session. + session_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -144,7 +144,7 @@ async def asyncio( jobs. Args: - session_id (str): Unique ID of the session. + session_id (str): Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/list_sessions.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/list_sessions.py index 1ec02df..acaf20a 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/list_sessions.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/list_sessions.py @@ -95,14 +95,12 @@ def sync_detailed( Retrieve information about all sessions. Args: - platform_id (Union[Unset, str]): List sessions that have been created for this platform. - tags (Union[Unset, list[str]]): List sessions with these tags. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of sessions to return per page. - order_by (Union[Unset, ListSessionsOrderBy]): Sort order of the returned sessions. - Default: ListSessionsOrderBy.NAME_ASC. - project_id (str): List sessions belonging to this project ID. (UUID format) Example: - 6170692e-7363-616c-6577-61792e636f6d. + platform_id (Union[Unset, str]): + tags (Union[Unset, list[str]]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListSessionsOrderBy]): Default: ListSessionsOrderBy.NAME_ASC. + project_id (str): Example: 6170692e-7363-616c-6577-61792e636f6d. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -143,14 +141,12 @@ def sync( Retrieve information about all sessions. Args: - platform_id (Union[Unset, str]): List sessions that have been created for this platform. - tags (Union[Unset, list[str]]): List sessions with these tags. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of sessions to return per page. - order_by (Union[Unset, ListSessionsOrderBy]): Sort order of the returned sessions. - Default: ListSessionsOrderBy.NAME_ASC. - project_id (str): List sessions belonging to this project ID. (UUID format) Example: - 6170692e-7363-616c-6577-61792e636f6d. + platform_id (Union[Unset, str]): + tags (Union[Unset, list[str]]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListSessionsOrderBy]): Default: ListSessionsOrderBy.NAME_ASC. + project_id (str): Example: 6170692e-7363-616c-6577-61792e636f6d. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -186,14 +182,12 @@ async def asyncio_detailed( Retrieve information about all sessions. Args: - platform_id (Union[Unset, str]): List sessions that have been created for this platform. - tags (Union[Unset, list[str]]): List sessions with these tags. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of sessions to return per page. - order_by (Union[Unset, ListSessionsOrderBy]): Sort order of the returned sessions. - Default: ListSessionsOrderBy.NAME_ASC. - project_id (str): List sessions belonging to this project ID. (UUID format) Example: - 6170692e-7363-616c-6577-61792e636f6d. + platform_id (Union[Unset, str]): + tags (Union[Unset, list[str]]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListSessionsOrderBy]): Default: ListSessionsOrderBy.NAME_ASC. + project_id (str): Example: 6170692e-7363-616c-6577-61792e636f6d. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -232,14 +226,12 @@ async def asyncio( Retrieve information about all sessions. Args: - platform_id (Union[Unset, str]): List sessions that have been created for this platform. - tags (Union[Unset, list[str]]): List sessions with these tags. - page (Union[Unset, int]): Page number. - page_size (Union[Unset, int]): Maximum number of sessions to return per page. - order_by (Union[Unset, ListSessionsOrderBy]): Sort order of the returned sessions. - Default: ListSessionsOrderBy.NAME_ASC. - project_id (str): List sessions belonging to this project ID. (UUID format) Example: - 6170692e-7363-616c-6577-61792e636f6d. + platform_id (Union[Unset, str]): + tags (Union[Unset, list[str]]): + page (Union[Unset, int]): + page_size (Union[Unset, int]): + order_by (Union[Unset, ListSessionsOrderBy]): Default: ListSessionsOrderBy.NAME_ASC. + project_id (str): Example: 6170692e-7363-616c-6577-61792e636f6d. Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/terminate_session.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/terminate_session.py index 3c0dddf..26c073b 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/terminate_session.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/terminate_session.py @@ -65,7 +65,7 @@ def sync_detailed( Terminate a session by its unique ID and cancel all its attached jobs and booking. Args: - session_id (str): Unique ID of the session. + session_id (str): body (TerminateSessionBody): Raises: @@ -99,7 +99,7 @@ def sync( Terminate a session by its unique ID and cancel all its attached jobs and booking. Args: - session_id (str): Unique ID of the session. + session_id (str): body (TerminateSessionBody): Raises: @@ -128,7 +128,7 @@ async def asyncio_detailed( Terminate a session by its unique ID and cancel all its attached jobs and booking. Args: - session_id (str): Unique ID of the session. + session_id (str): body (TerminateSessionBody): Raises: @@ -160,7 +160,7 @@ async def asyncio( Terminate a session by its unique ID and cancel all its attached jobs and booking. Args: - session_id (str): Unique ID of the session. + session_id (str): body (TerminateSessionBody): Raises: diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/update_session.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/update_session.py index 0de62b5..0f8b3f6 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/update_session.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/api/sessions/update_session.py @@ -65,7 +65,7 @@ def sync_detailed( Update session information of the provided **session ID**. Args: - session_id (str): Unique ID of the session. + session_id (str): body (UpdateSessionBody): Raises: @@ -99,7 +99,7 @@ def sync( Update session information of the provided **session ID**. Args: - session_id (str): Unique ID of the session. + session_id (str): body (UpdateSessionBody): Raises: @@ -128,7 +128,7 @@ async def asyncio_detailed( Update session information of the provided **session ID**. Args: - session_id (str): Unique ID of the session. + session_id (str): body (UpdateSessionBody): Raises: @@ -160,7 +160,7 @@ async def asyncio( Update session information of the provided **session ID**. Args: - session_id (str): Unique ID of the session. + session_id (str): body (UpdateSessionBody): Raises: diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/create_session_body_booking_demand.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/create_session_body_booking_demand.py index f3f9e0a..d3aaedc 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/create_session_body_booking_demand.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/create_session_body_booking_demand.py @@ -19,11 +19,13 @@ class CreateSessionBodyBookingDemand: started_at (Union[None, Unset, datetime.datetime]): (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z. finished_at (Union[None, Unset, datetime.datetime]): (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z. description (Union[None, Unset, str]): + time_zone (Union[None, Unset, str]): """ started_at: Union[None, Unset, datetime.datetime] = UNSET finished_at: Union[None, Unset, datetime.datetime] = UNSET description: Union[None, Unset, str] = UNSET + time_zone: Union[None, Unset, str] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -49,6 +51,12 @@ def to_dict(self) -> dict[str, Any]: else: description = self.description + time_zone: Union[None, Unset, str] + if isinstance(self.time_zone, Unset): + time_zone = UNSET + else: + time_zone = self.time_zone + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) @@ -58,6 +66,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["finished_at"] = finished_at if description is not UNSET: field_dict["description"] = description + if time_zone is not UNSET: + field_dict["time_zone"] = time_zone return field_dict @@ -108,10 +118,20 @@ def _parse_description(data: object) -> Union[None, Unset, str]: description = _parse_description(d.pop("description", UNSET)) + def _parse_time_zone(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + time_zone = _parse_time_zone(d.pop("time_zone", UNSET)) + create_session_body_booking_demand = cls( started_at=started_at, finished_at=finished_at, description=description, + time_zone=time_zone, ) create_session_body_booking_demand.additional_properties = d diff --git a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/scaleway_qaas_v1_alpha_1_booking.py b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/scaleway_qaas_v1_alpha_1_booking.py index 3931a20..3f340fd 100644 --- a/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/scaleway_qaas_v1_alpha_1_booking.py +++ b/scaleway_qaas_client/v1alpha1/quantum_as_a_service_api_client/models/scaleway_qaas_v1_alpha_1_booking.py @@ -31,6 +31,8 @@ class ScalewayQaasV1Alpha1Booking: ScalewayQaasV1Alpha1BookingStatus.UNKNOWN_STATUS. description (Union[Unset, str]): Description of the booking slot. progress_message (Union[Unset, str]): Any progress message of the booking. + time_zone (Union[None, Unset, str]): Time zone for the booking schedule, in tz database format (e.g. + 'Europe/Paris'). """ id: Union[Unset, str] = UNSET @@ -43,6 +45,7 @@ class ScalewayQaasV1Alpha1Booking: ) description: Union[Unset, str] = UNSET progress_message: Union[Unset, str] = UNSET + time_zone: Union[None, Unset, str] = UNSET additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict) def to_dict(self) -> dict[str, Any]: @@ -88,6 +91,12 @@ def to_dict(self) -> dict[str, Any]: progress_message = self.progress_message + time_zone: Union[None, Unset, str] + if isinstance(self.time_zone, Unset): + time_zone = UNSET + else: + time_zone = self.time_zone + field_dict: dict[str, Any] = {} field_dict.update(self.additional_properties) field_dict.update({}) @@ -107,6 +116,8 @@ def to_dict(self) -> dict[str, Any]: field_dict["description"] = description if progress_message is not UNSET: field_dict["progress_message"] = progress_message + if time_zone is not UNSET: + field_dict["time_zone"] = time_zone return field_dict @@ -194,6 +205,15 @@ def _parse_finished_at(data: object) -> Union[None, Unset, datetime.datetime]: progress_message = d.pop("progress_message", UNSET) + def _parse_time_zone(data: object) -> Union[None, Unset, str]: + if data is None: + return data + if isinstance(data, Unset): + return data + return cast(Union[None, Unset, str], data) + + time_zone = _parse_time_zone(d.pop("time_zone", UNSET)) + scaleway_qaas_v1_alpha_1_booking = cls( id=id, created_at=created_at, @@ -203,6 +223,7 @@ def _parse_finished_at(data: object) -> Union[None, Unset, datetime.datetime]: status=status, description=description, progress_message=progress_message, + time_zone=time_zone, ) scaleway_qaas_v1_alpha_1_booking.additional_properties = d diff --git a/scaleway_qaas_client/v1alpha1/utils.py b/scaleway_qaas_client/v1alpha1/utils.py new file mode 100644 index 0000000..2099d07 --- /dev/null +++ b/scaleway_qaas_client/v1alpha1/utils.py @@ -0,0 +1,20 @@ +def is_valid_iana(time_zone: str) -> bool: + import pytz + + if not time_zone: + return False + try: + pytz.timezone(time_zone) + return True + except pytz.exceptions.UnknownTimeZoneError: + return False + + +def get_local_iana_timezone() -> str: + import tzlocal + + try: + tz_name = tzlocal.get_localzone_name() + return tz_name + except Exception: + return "UTC" diff --git a/tests/test_booking.py b/tests/test_booking.py index 1534f5a..295abb7 100644 --- a/tests/test_booking.py +++ b/tests/test_booking.py @@ -13,9 +13,9 @@ # limitations under the License. import os import time -import uuid from datetime import datetime, timedelta, timezone + from scaleway_qaas_client.v1alpha1 import QaaSClient _TEST_PLATFORM_NAME = os.environ.get("TEST_PLATFORM_NAME", "aer_simulation_pop_c16m128") From d0d661b5cf03c617d8995b3bbf0e1d085ece9287 Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Wed, 22 Oct 2025 13:51:07 +0200 Subject: [PATCH 11/13] feat(qaas): wip timezone --- requirements.txt | 4 +--- scaleway_qaas_client/v1alpha1/client.py | 28 +++++------------------- scaleway_qaas_client/v1alpha1/utils.py | 20 ----------------- tests/requirements.txt | 3 ++- tests/test_booking.py | 29 ++++++++++++++++--------- 5 files changed, 27 insertions(+), 57 deletions(-) delete mode 100644 scaleway_qaas_client/v1alpha1/utils.py diff --git a/requirements.txt b/requirements.txt index 8b79b3a..35ef2e0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,4 @@ randomname>=0.2.1 httpx>=0.27.0 pytimeparse>=1.1.8 attrs>=22.2.0 -python-dateutil>=2.8.0 -pytz>=2024.1 -tzlocal>=5.3.1 \ No newline at end of file +python-dateutil>=2.8.0 \ No newline at end of file diff --git a/scaleway_qaas_client/v1alpha1/client.py b/scaleway_qaas_client/v1alpha1/client.py index 0c0fc13..5e50564 100644 --- a/scaleway_qaas_client/v1alpha1/client.py +++ b/scaleway_qaas_client/v1alpha1/client.py @@ -127,8 +127,6 @@ Response, ) -from scaleway_qaas_client.v1alpha1.utils import get_local_iana_timezone, is_valid_iana - _DEFAULT_URL = "https://api.scaleway.com" @@ -253,7 +251,6 @@ def create_session( booking_demand_started_at: Optional[datetime] = None, booking_demand_finished_at: Optional[datetime] = None, booking_demand_description: Optional[str] = None, - booking_demand_time_zone: Optional[str] = None, ) -> ScalewayQaasV1Alpha1Session: """Create a session @@ -267,10 +264,9 @@ def create_session( max_duration (Union[None, Unset, str]): Maximum duration before the session ends. (in seconds) Example: 20m. deduplication_id (Union[None, Unset, str]): Deduplication ID of the session. model_id (Union[None, Unset, str]): Default computation model ID to be executed by job assigned to this session. - booking_demand_started_at (Union[None, Unset, datetime.datetime]): Wished started time for an exclusive session over a QPU, only works if the platform is_bookable (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z. - booking_demand_finished_at (Union[None, Unset, datetime.datetime]): Wished finished time for an exclusive session over a QPU, only works if the platform is_bookable (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z. + booking_demand_started_at (Union[None, Unset, datetime.datetime]): Wished started UTC time for an exclusive session over a QPU, only works if the platform is_bookable (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z. + booking_demand_finished_at (Union[None, Unset, datetime.datetime]): Wished finished UTC time for an exclusive session over a QPU, only works if the platform is_bookable (RFC 3339 format) Example: 2022-03-22T12:34:56.123456Z. booking_demand_description (Union[None, Unset, str]): User description of the booking - booking_demand_time_zone (Union[None, Unset, str]): Time zone of the demanded booking (eg: Europe/Paris, America/New_York...) Raises: errors.UnexpectedStatus: If the server returns an undocumented status code and Client.raise_on_unexpected_status is True. @@ -309,25 +305,11 @@ def create_session( booking_demand = UNSET if booking_demand_started_at and booking_demand_finished_at: - booking_demand_started_at_timestamp = booking_demand_started_at.timestamp() - booking_demand_finished_at_timestamp = ( - booking_demand_finished_at.timestamp() - ) - - if booking_demand_time_zone is not None and not is_valid_iana( - booking_demand_time_zone - ): - raise Exception( - f"create_session: invalid time zone {booking_demand_time_zone} as IANA format" - ) - else: - time_zone = get_local_iana_timezone() - booking_demand = CreateSessionBodyBookingDemand( - started_at=booking_demand_started_at_timestamp, - finished_at=booking_demand_finished_at_timestamp, + started_at=booking_demand_started_at, + finished_at=booking_demand_finished_at, description=booking_demand_description, - time_zone=time_zone, + time_zone="UTC", ) response = _create_session_sync( diff --git a/scaleway_qaas_client/v1alpha1/utils.py b/scaleway_qaas_client/v1alpha1/utils.py deleted file mode 100644 index 2099d07..0000000 --- a/scaleway_qaas_client/v1alpha1/utils.py +++ /dev/null @@ -1,20 +0,0 @@ -def is_valid_iana(time_zone: str) -> bool: - import pytz - - if not time_zone: - return False - try: - pytz.timezone(time_zone) - return True - except pytz.exceptions.UnknownTimeZoneError: - return False - - -def get_local_iana_timezone() -> str: - import tzlocal - - try: - tz_name = tzlocal.get_localzone_name() - return tz_name - except Exception: - return "UTC" diff --git a/tests/requirements.txt b/tests/requirements.txt index 5b61bc2..883fcfb 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,5 @@ pytest pytest-dependency pytest-progress -pytest-httpx \ No newline at end of file +pytest-httpx +pytz \ No newline at end of file diff --git a/tests/test_booking.py b/tests/test_booking.py index 295abb7..391d8cf 100644 --- a/tests/test_booking.py +++ b/tests/test_booking.py @@ -13,6 +13,7 @@ # limitations under the License. import os import time +import pytz from datetime import datetime, timedelta, timezone @@ -21,6 +22,14 @@ _TEST_PLATFORM_NAME = os.environ.get("TEST_PLATFORM_NAME", "aer_simulation_pop_c16m128") +def _get_now_utc() -> datetime: + return datetime.now(timezone.utc) + + +def _get_now_paris() -> datetime: + return datetime.now(pytz.timezone("Europe/Paris")) + + def _get_client() -> QaaSClient: client = QaaSClient( project_id=os.environ["SCALEWAY_PROJECT_ID"], @@ -41,8 +50,8 @@ def test_create_and_cancel_booking(): target_platform = platforms[0] try: - now = datetime.now(timezone.utc) - booking_start = now + timedelta(seconds=15) + now = _get_now_paris() + booking_start = now + timedelta(seconds=16) booking_finish = booking_start + timedelta(seconds=20) booking_description = "my lovely booking" @@ -100,7 +109,7 @@ def test_create_overlaping_booking(): target_platform = platforms[0] - now = datetime.now(timezone.utc) + now = _get_now_paris() booking_start = now + timedelta(days=1) booking_finish = booking_start + timedelta(hours=1) booking_description = "my overlaping booking" @@ -127,7 +136,7 @@ def test_create_too_long_booking(): target_platform = platforms[0] - now = datetime.now(timezone.utc) + now = _get_now_paris() booking_start = now + timedelta(minutes=1) booking_finish = booking_start + timedelta(hours=10) booking_description = "my too long booking" @@ -152,7 +161,7 @@ def test_create_too_short_booking(): target_platform = platforms[0] - now = datetime.now(timezone.utc) + now = _get_now_paris() booking_start = now + timedelta(minutes=1) booking_finish = booking_start + timedelta(seconds=10) booking_description = "my lovely booking" @@ -177,7 +186,7 @@ def test_create_too_far_booking(): target_platform = platforms[0] - now = datetime.now(timezone.utc) + now = _get_now_paris() booking_start = now + timedelta(days=30) booking_finish = booking_start + timedelta(hours=2) booking_description = "my lovely booking" @@ -202,7 +211,7 @@ def test_create_too_close_booking(): target_platform = platforms[0] - now = datetime.now(timezone.utc) + now = _get_now_paris() booking_start = now + timedelta(seconds=10) booking_finish = booking_start + timedelta(hours=2) booking_description = "my lovely booking" @@ -227,7 +236,7 @@ def test_stop_too_close_booking(): target_platform = platforms[0] - now = datetime.now(timezone.utc) + now = _get_now_paris() booking_start = now + timedelta(seconds=20) booking_finish = booking_start + timedelta(seconds=30) booking_description = "my lovely booking" @@ -273,7 +282,7 @@ def test_cannot_start_not_booked_session_during_booked_session_is_running(): target_platform = platforms[0] - now = datetime.now(timezone.utc) + now = _get_now_paris() booking_start = now + timedelta(seconds=20) booking_finish = booking_start + timedelta(seconds=20) booking_description = "my booking" @@ -347,7 +356,7 @@ def test_not_booked_session_is_killed_when_booked_session_starts(): assert not_booked_session_2 - now = datetime.now(timezone.utc) + now = _get_now_paris() booking_start = now + timedelta(seconds=20) booking_finish = booking_start + timedelta(seconds=20) booking_description = "my booking" From 08047b864bb2f476d0aff39308e07bf5b679b11a Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Wed, 22 Oct 2025 14:06:36 +0200 Subject: [PATCH 12/13] feat(qaas): clear --- tests/test_api.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 2f8de8a..41a0a61 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -127,9 +127,6 @@ def test_create_delete_session(): max_idle_duration=max_idle_duration, ) - print(session.updated_at) - print(session.created_at) - assert session is not None assert session.id is not None assert session.platform_id == target_platform.id From e73606d9fa2e33f8d2c0daed1d3896b846366769 Mon Sep 17 00:00:00 2001 From: Valentin Macheret Date: Wed, 22 Oct 2025 14:15:07 +0200 Subject: [PATCH 13/13] feat(qaas): clear --- tests/test_api.py | 386 +--------------------------------------------- 1 file changed, 2 insertions(+), 384 deletions(-) diff --git a/tests/test_api.py b/tests/test_api.py index 41a0a61..848f443 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -168,94 +168,14 @@ def test_list_platform_bookings(): assert len(bookings) > 0 -def test_create_and_cancel_booking(): - client = _get_client() - - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - for platform in platforms: - assert platform.name == _TEST_PLATFORM_NAME - - assert len(platforms) > 0 - - -def test_list_platforms_by_unexisting_name(): - client = _get_client() - - platforms = client.list_platforms(name=_RANDOM_UUID) - - assert platforms == [] - - -def test_list_sessions_unexisting_platform(): - client = _get_client() - - sessions = client.list_sessions(platform_id=_RANDOM_UUID) - - assert sessions == [] - - -def test_create_delete_session(): - client = _get_client() - - try: - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert platforms is not None - assert len(platforms) == 1 - - target_platform = platforms[0] - - assert target_platform.id is not None - - max_duration = "2m" - max_idle_duration = "2m" - - session = client.create_session( - platform_id=target_platform.id, - max_duration=max_duration, - max_idle_duration=max_idle_duration, - ) - - print(session.updated_at) - print(session.created_at) - - assert session is not None - assert session.id is not None - assert session.platform_id == target_platform.id - - while session.status == "starting": - session = client.get_session(session.id) - time.sleep(3) - - assert session.status == "running" - - while True: - time.sleep(2) - session = client.get_session(session_id=session.id) - booking = client.get_booking(booking_id=session.booking_id) - - print(session.status, booking.status) - - assert session.status in ["starting", "running"] - assert booking.status in ["waiting", "validating", "validated"] - - if booking.status == "validated": - break - - finally: - client.delete_session(session.id) - - while True: - time.sleep(2) - booking = client.get_booking(booking_id=session.booking_id) - def test_create_session_same_deduplication_id(): client = _get_client() try: platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) + assert len(platforms) > 0 + platform = platforms[0] max_duration = "2m" @@ -291,305 +211,3 @@ def test_create_session_same_deduplication_id(): assert second_session.deduplication_id == session.deduplication_id finally: client.delete_session(session.id) - - -def test_create_overlaping_booking(): - client = _get_client() - - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert len(platforms) > 0 - - target_platform = platforms[0] - - now = datetime.now(timezone.utc) - booking_start = now + timedelta(days=1) - booking_finish = booking_start + timedelta(hours=1) - booking_description = "my overlaping booking" - - try: - session = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - - assert session == None - except Exception as e: - assert "existing booking" in str(e) - - -def test_create_too_long_booking(): - client = _get_client() - - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert len(platforms) > 0 - - target_platform = platforms[0] - - now = datetime.now(timezone.utc) - booking_start = now + timedelta(minutes=1) - booking_finish = booking_start + timedelta(hours=10) - booking_description = "my too long booking" - - try: - _ = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - except Exception as e: - assert "max_duration not respected" in str(e) - - -def test_create_too_short_booking(): - client = _get_client() - - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert len(platforms) > 0 - - target_platform = platforms[0] - - now = datetime.now(timezone.utc) - booking_start = now + timedelta(minutes=1) - booking_finish = booking_start + timedelta(seconds=10) - booking_description = "my lovely booking" - - try: - _ = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - except Exception as e: - assert "min_duration not respected" in str(e) - - -def test_create_too_far_booking(): - client = _get_client() - - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert len(platforms) > 0 - - target_platform = platforms[0] - - now = datetime.now(timezone.utc) - booking_start = now + timedelta(days=30) - booking_finish = booking_start + timedelta(hours=2) - booking_description = "my lovely booking" - - try: - _ = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - except Exception as e: - assert "max_planification_duration not respected" in str(e) - - -def test_create_too_close_booking(): - client = _get_client() - - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert len(platforms) > 0 - - target_platform = platforms[0] - - now = datetime.now(timezone.utc) - booking_start = now + timedelta(seconds=10) - booking_finish = booking_start + timedelta(hours=2) - booking_description = "my lovely booking" - - try: - _ = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - except Exception as e: - assert "min_planification_duration not respected" in str(e) - - -def test_stop_too_close_booking(): - client = _get_client() - - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert len(platforms) > 0 - - target_platform = platforms[0] - - now = datetime.now(timezone.utc) - booking_start = now + timedelta(seconds=20) - booking_finish = booking_start + timedelta(seconds=30) - booking_description = "my lovely booking" - - try: - session = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - - time.sleep(15) - - session = client.terminate_session(session.id) - - while session.status == "stopping": - session = client.get_session(session.id) - time.sleep(3) - - assert session.status in ["starting", "running"] - - if session.status == "running": - break - - except Exception as e: - assert "max_cancellation_time passed" in str(e) - - while True: - session = client.get_session(session.id) - - assert session.status in ["starting", "running", "stopped"] - - if session.status == "stopped": - break - - -def test_cannot_start_not_booked_session_during_booked_session_is_running(): - client = _get_client() - - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert len(platforms) > 0 - - target_platform = platforms[0] - - now = datetime.now(timezone.utc) - booking_start = now + timedelta(seconds=20) - booking_finish = booking_start + timedelta(seconds=20) - booking_description = "my booking" - - booked_session = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - - while True: - time.sleep(2) - booked_session = client.get_session(session_id=booked_session.id) - - assert booked_session.status in ["starting", "running"] - - if booked_session.status == "running": - break - - not_booked_session = client.create_session( - platform_id=target_platform.id, - ) - - while True: - time.sleep(2) - not_booked_session = client.get_session(session_id=not_booked_session.id) - booked_session = client.get_session(session_id=booked_session.id) - - assert ( - not_booked_session.status == "starting" - if booked_session.status == "running" - else "running" - ) - assert booked_session.status in ["running", "stopping", "stopped"] - - if booked_session.status == "stopped": - break - - while True: - time.sleep(2) - not_booked_session = client.get_session(session_id=not_booked_session.id) - - assert not_booked_session.status in ["starting", "running"] - - if not_booked_session.status == "running": - break - - client.delete_session(not_booked_session.id) - - -def test_not_booked_session_is_killed_when_booked_session_starts(): - client = _get_client() - - platforms = client.list_platforms(name=_TEST_PLATFORM_NAME) - - assert len(platforms) > 0 - - target_platform = platforms[0] - - try: - not_booked_session_1 = client.create_session( - platform_id=target_platform.id, - ) - - assert not_booked_session_1 - - not_booked_session_2 = client.create_session( - platform_id=target_platform.id, - ) - - assert not_booked_session_2 - - now = datetime.now(timezone.utc) - booking_start = now + timedelta(seconds=20) - booking_finish = booking_start + timedelta(seconds=20) - booking_description = "my booking" - - booked_session = client.create_session( - platform_id=target_platform.id, - booking_demand_started_at=booking_start, - booking_demand_finished_at=booking_finish, - booking_demand_description=booking_description, - ) - - while True: - time.sleep(2) - - not_booked_session_1 = client.get_session( - session_id=not_booked_session_1.id - ) - not_booked_session_2 = client.get_session( - session_id=not_booked_session_2.id - ) - booked_session = client.get_session(session_id=booked_session.id) - - assert not_booked_session_1.status in ["starting", "running"] - assert not_booked_session_2.status in ["starting", "running"] - assert booked_session.status in ["starting"] - - if ( - not_booked_session_1.status == "running" - and not_booked_session_2.status == "running" - ): - break - - while True: - time.sleep(2) - - booked_session = client.get_session(session_id=booked_session.id) - -# if ( -# not_booked_session_1.status == "stopped" -# and not_booked_session_2.status == "stopped" -# ): -# break