Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
196 changes: 196 additions & 0 deletions cirro_api_client/v1/api/execution/get_task_files.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
from http import HTTPStatus
from typing import Any
from urllib.parse import quote

import httpx

from ... import errors
from ...client import Client
from ...models.task_files_response import TaskFilesResponse
from ...types import Response


def _get_kwargs(
project_id: str,
dataset_id: str,
task_id: str,
) -> dict[str, Any]:
_kwargs: dict[str, Any] = {
"method": "get",
"url": "/projects/{project_id}/execution/{dataset_id}/tasks/{task_id}/files".format(
project_id=quote(str(project_id), safe=""),
dataset_id=quote(str(dataset_id), safe=""),
task_id=quote(str(task_id), safe=""),
),
}

return _kwargs


def _parse_response(*, client: Client, response: httpx.Response) -> TaskFilesResponse | None:
if response.status_code == 200:
return TaskFilesResponse.from_dict(response.json())

errors.handle_error_response(response, client.raise_on_unexpected_status)


def _build_response(*, client: Client, response: httpx.Response) -> Response[TaskFilesResponse | None]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
headers=response.headers,
parsed=_parse_response(client=client, response=response),
)


def sync_detailed(
project_id: str,
dataset_id: str,
task_id: str,
*,
client: Client,
) -> Response[TaskFilesResponse | None]:
"""Get task input and output files

Gets the input and output files for an individual task.
Returns 400 for non-Nextflow executions and 404 if the task or
work directory is not found.

Args:
project_id (str):
dataset_id (str):
task_id (str):
client (Client): instance of the API client

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[TaskFilesResponse | None]
"""

kwargs = _get_kwargs(
project_id=project_id,
dataset_id=dataset_id,
task_id=task_id,
)

response = client.get_httpx_client().request(
auth=client.get_auth(),
**kwargs,
)

return _build_response(client=client, response=response)


def sync(
project_id: str,
dataset_id: str,
task_id: str,
*,
client: Client,
) -> TaskFilesResponse | None:
"""Get task input and output files

Gets the input and output files for an individual task.
Returns 400 for non-Nextflow executions and 404 if the task or
work directory is not found.

Args:
project_id (str):
dataset_id (str):
task_id (str):
client (Client): instance of the API client

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:
TaskFilesResponse | None
"""

try:
return sync_detailed(
project_id=project_id,
dataset_id=dataset_id,
task_id=task_id,
client=client,
).parsed
except (errors.NotFoundException, errors.BadRequestException):
return None


async def asyncio_detailed(
project_id: str,
dataset_id: str,
task_id: str,
*,
client: Client,
) -> Response[TaskFilesResponse | None]:
"""Get task input and output files

Gets the input and output files for an individual task.

Args:
project_id (str):
dataset_id (str):
task_id (str):
client (Client): instance of the API client

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[TaskFilesResponse | None]
"""

kwargs = _get_kwargs(
project_id=project_id,
dataset_id=dataset_id,
task_id=task_id,
)

response = await client.get_async_httpx_client().request(auth=client.get_auth(), **kwargs)

return _build_response(client=client, response=response)


async def asyncio(
project_id: str,
dataset_id: str,
task_id: str,
*,
client: Client,
) -> TaskFilesResponse | None:
"""Get task input and output files

Gets the input and output files for an individual task.

Args:
project_id (str):
dataset_id (str):
task_id (str):
client (Client): instance of the API client

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:
TaskFilesResponse | None
"""

try:
return (
await asyncio_detailed(
project_id=project_id,
dataset_id=dataset_id,
task_id=task_id,
client=client,
)
).parsed
except (errors.NotFoundException, errors.BadRequestException):
return None
4 changes: 4 additions & 0 deletions cirro_api_client/v1/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@
from .tag import Tag
from .task import Task
from .task_cost import TaskCost
from .task_file import TaskFile
from .task_files_response import TaskFilesResponse
from .tenant_info import TenantInfo
from .trigger_ingest_request import TriggerIngestRequest
from .update_dataset_request import UpdateDatasetRequest
Expand Down Expand Up @@ -447,6 +449,8 @@
"Tag",
"Task",
"TaskCost",
"TaskFile",
"TaskFilesResponse",
"TenantInfo",
"TriggerIngestRequest",
"UpdateDatasetRequest",
Expand Down
60 changes: 60 additions & 0 deletions cirro_api_client/v1/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class Task:
container_image (None | str | Unset):
command_line (None | str | Unset):
log_location (None | str | Unset):
work_dir (None | str | Unset): S3 URI of the task's work directory
exit_code (int | None | Unset): Process exit code
hash (None | str | Unset): Short hash prefix used by Nextflow, e.g. ``99/b42c07``
"""

name: str
Expand All @@ -39,6 +42,9 @@ class Task:
container_image: None | str | Unset = UNSET
command_line: None | str | Unset = UNSET
log_location: None | str | Unset = UNSET
work_dir: None | str | Unset = UNSET
exit_code: int | None | Unset = UNSET
hash: None | str | Unset = UNSET
additional_properties: dict[str, Any] = _attrs_field(init=False, factory=dict)

def to_dict(self) -> dict[str, Any]:
Expand Down Expand Up @@ -100,6 +106,24 @@ def to_dict(self) -> dict[str, Any]:
else:
log_location = self.log_location

work_dir: None | str | Unset
if isinstance(self.work_dir, Unset):
work_dir = UNSET
else:
work_dir = self.work_dir

exit_code: int | None | Unset
if isinstance(self.exit_code, Unset):
exit_code = UNSET
else:
exit_code = self.exit_code

hash_: None | str | Unset
if isinstance(self.hash, Unset):
hash_ = UNSET
else:
hash_ = self.hash

field_dict: dict[str, Any] = {}
field_dict.update(self.additional_properties)
field_dict.update(
Expand All @@ -124,6 +148,12 @@ def to_dict(self) -> dict[str, Any]:
field_dict["commandLine"] = command_line
if log_location is not UNSET:
field_dict["logLocation"] = log_location
if work_dir is not UNSET:
field_dict["workDir"] = work_dir
if exit_code is not UNSET:
field_dict["exitCode"] = exit_code
if hash_ is not UNSET:
field_dict["hash"] = hash_

return field_dict

Expand Down Expand Up @@ -230,6 +260,33 @@ def _parse_log_location(data: object) -> None | str | Unset:

log_location = _parse_log_location(d.pop("logLocation", UNSET))

def _parse_work_dir(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)

work_dir = _parse_work_dir(d.pop("workDir", UNSET))

def _parse_exit_code(data: object) -> int | None | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return int(data) # type: ignore[call-overload]

exit_code = _parse_exit_code(d.pop("exitCode", UNSET))

def _parse_hash(data: object) -> None | str | Unset:
if data is None:
return data
if isinstance(data, Unset):
return data
return cast(None | str | Unset, data)

hash_ = _parse_hash(d.pop("hash", UNSET))

task = cls(
name=name,
status=status,
Expand All @@ -241,6 +298,9 @@ def _parse_log_location(data: object) -> None | str | Unset:
container_image=container_image,
command_line=command_line,
log_location=log_location,
work_dir=work_dir,
exit_code=exit_code,
hash=hash_,
)

task.additional_properties = d
Expand Down
Loading
Loading