cirro.services
1from .billing import BillingService 2from .dataset import DatasetService 3from .execution import ExecutionService 4from .file import FileService 5from .metadata import MetadataService 6from .metrics import MetricsService 7from .process import ProcessService 8from .projects import ProjectService 9from .references import ReferenceService 10 11__all__ = [ 12 'BillingService', 13 'DatasetService', 14 'ExecutionService', 15 'FileService', 16 'MetadataService', 17 'MetricsService', 18 'ProcessService', 19 'ProjectService', 20 'ReferenceService' 21]
10class BillingService(BaseService): 11 """ 12 Service for interacting with the Billing endpoints 13 """ 14 def list(self) -> List[BillingAccount]: 15 """ 16 Gets a list of billing accounts the current user has access to 17 """ 18 return get_billing_accounts.sync(client=self._api_client) 19 20 def update(self, billing_account_id: str, request: BillingAccountRequest): 21 """ 22 Updates a billing account 23 24 Args: 25 billing_account_id (str): Billing account ID 26 request (cirro_api_client.v1.models.BillingAccountRequest): 27 28 ```python 29 from cirro_api_client.v1.models import BillingAccountRequest 30 from cirro.cirro_client import CirroApi 31 32 cirro = CirroApi() 33 request = BillingAccountRequest( 34 name="New billing account name", 35 primary_budget_number="new-budget-number", 36 owner="New Owner" 37 ) 38 cirro.billing.update("billing-account-id", request) 39 ``` 40 """ 41 update_billing_account.sync_detailed( 42 billing_account_id=billing_account_id, 43 body=request, 44 client=self._api_client 45 )
Service for interacting with the Billing endpoints
14 def list(self) -> List[BillingAccount]: 15 """ 16 Gets a list of billing accounts the current user has access to 17 """ 18 return get_billing_accounts.sync(client=self._api_client)
Gets a list of billing accounts the current user has access to
20 def update(self, billing_account_id: str, request: BillingAccountRequest): 21 """ 22 Updates a billing account 23 24 Args: 25 billing_account_id (str): Billing account ID 26 request (cirro_api_client.v1.models.BillingAccountRequest): 27 28 ```python 29 from cirro_api_client.v1.models import BillingAccountRequest 30 from cirro.cirro_client import CirroApi 31 32 cirro = CirroApi() 33 request = BillingAccountRequest( 34 name="New billing account name", 35 primary_budget_number="new-budget-number", 36 owner="New Owner" 37 ) 38 cirro.billing.update("billing-account-id", request) 39 ``` 40 """ 41 update_billing_account.sync_detailed( 42 billing_account_id=billing_account_id, 43 body=request, 44 client=self._api_client 45 )
Updates a billing account
Arguments:
- billing_account_id (str): Billing account ID
- request (cirro_api_client.v1.models.BillingAccountRequest):
from cirro_api_client.v1.models import BillingAccountRequest
from cirro.cirro_client import CirroApi
cirro = CirroApi()
request = BillingAccountRequest(
name="New billing account name",
primary_budget_number="new-budget-number",
owner="New Owner"
)
cirro.billing.update("billing-account-id", request)
Inherited Members
- cirro.services.base.BaseService
- BaseService
14class DatasetService(FileEnabledService): 15 """ 16 Service for interacting with the Dataset endpoints 17 """ 18 def list(self, project_id: str, max_items: int = 10000) -> List[Dataset]: 19 """List datasets 20 21 Retrieves a list of datasets for a given project 22 23 Args: 24 project_id (str): ID of the Project 25 max_items (int): Maximum number of records to get (default 10,000) 26 """ 27 return get_all_records( 28 records_getter=lambda page_args: get_datasets.sync( 29 project_id=project_id, 30 client=self._api_client, 31 next_token=page_args.next_token, 32 limit=page_args.limit 33 ), 34 max_items=max_items 35 ) 36 37 def import_public(self, project_id: str, import_request: ImportDataRequest) -> CreateResponse: 38 """ 39 Download data from public repositories 40 41 Args: 42 project_id (str): ID of the Project 43 import_request (cirro_api_client.v1.models.ImportDataRequest): 44 45 Returns: 46 ID of the created dataset 47 """ 48 return import_public_dataset.sync(project_id=project_id, client=self._api_client, body=import_request) 49 50 def create(self, project_id: str, upload_request: UploadDatasetRequest) -> UploadDatasetCreateResponse: 51 """ 52 Registers a dataset in Cirro, which can subsequently have files uploaded to it 53 54 Args: 55 project_id (str): ID of the Project 56 upload_request (cirro_api_client.v1.models.UploadDatasetRequest): 57 58 Returns: 59 ID of the created dataset and the path to upload files 60 61 ```python 62 from cirro_api_client.v1.models import UploadDatasetRequest 63 from cirro.cirro_client import CirroApi 64 65 cirro = CirroApi() 66 request = UploadDatasetRequest( 67 name="Name of new dataset", 68 process_id="paired_dnaseq", 69 expected_files=["read_1.fastq.gz", "read_2.fastq.gz"], 70 description="Description of the dataset" 71 ) 72 cirro.datasets.create("project-id", request) 73 ``` 74 """ 75 return upload_dataset.sync(project_id=project_id, client=self._api_client, body=upload_request) 76 77 def get(self, project_id: str, dataset_id: str) -> Optional[DatasetDetail]: 78 """ 79 Gets detailed information about a dataset 80 81 Args: 82 project_id (str): ID of the Project 83 dataset_id (str): ID of the Dataset 84 85 Returns: 86 The dataset, if found 87 """ 88 return get_dataset.sync(project_id=project_id, dataset_id=dataset_id, client=self._api_client) 89 90 def update(self, project_id: str, dataset_id: str, request: UpdateDatasetRequest) -> DatasetDetail: 91 """ 92 Update info on a dataset (name, description, and/or tags) 93 94 Args: 95 project_id (str): ID of the Project 96 dataset_id (str): ID of the Dataset 97 request (cirro_api_client.v1.models.UpdateDatasetRequest): 98 99 Returns: 100 The updated dataset 101 102 ```python 103 from cirro_api_client.v1.models import UpdateDatasetRequest 104 from cirro.cirro_client import CirroApi 105 106 cirro = CirroApi() 107 request = UpdateDatasetRequest( 108 name="Name of new dataset", 109 process_id="paired_dnaseq", 110 description="Description of the dataset" 111 ) 112 cirro.datasets.update("project-id", "dataset-id", request) 113 ``` 114 """ 115 return update_dataset.sync(project_id=project_id, dataset_id=dataset_id, body=request, client=self._api_client) 116 117 def delete(self, project_id: str, dataset_id: str) -> None: 118 """ 119 Delete a dataset 120 121 After a dataset has been deleted, the files associated with that 122 dataset are saved according to the project's retention time. 123 124 Args: 125 project_id (str): ID of the Project 126 dataset_id (str): ID of the Dataset 127 """ 128 delete_dataset.sync_detailed(project_id=project_id, dataset_id=dataset_id, client=self._api_client) 129 130 def get_file_listing(self, project_id: str, dataset_id: str) -> List[File]: 131 """ 132 Gets a listing of files, charts, and other assets available for the dataset 133 134 Args: 135 project_id (str): ID of the Project 136 dataset_id (str): ID of the Dataset 137 """ 138 manifest = get_dataset_manifest.sync( 139 project_id=project_id, 140 dataset_id=dataset_id, 141 client=self._api_client 142 ) 143 144 files = [ 145 File.from_file_entry( 146 f, 147 project_id=project_id, 148 domain=manifest.domain 149 ) 150 for f in manifest.files 151 ] 152 return files 153 154 def upload_files(self, project_id: str, dataset_id: str, local_directory: str, files: List[str]) -> None: 155 """ 156 Uploads files to a given dataset from the specified local directory 157 158 Args: 159 project_id (str): ID of the Project 160 dataset_id (str): ID of the Dataset 161 local_directory (str): Path to local directory 162 files (typing.List[str]): List of relative paths to files within the local directory 163 164 """ 165 dataset = self.get(project_id, dataset_id) 166 167 access_context = FileAccessContext.upload_dataset( 168 project_id=project_id, 169 dataset_id=dataset_id, 170 base_url=dataset.s3 171 ) 172 173 self._file_service.upload_files( 174 access_context, 175 local_directory, 176 files 177 ) 178 179 def download_files( 180 self, 181 project_id: str, 182 dataset_id: str, 183 download_location: str, 184 files: Union[List[File], List[str]] = None 185 ) -> None: 186 """ 187 Downloads files from a dataset 188 189 The `files` argument is used to optionally specify a subset of files 190 to be downloaded. By default, all files are downloaded. 191 192 Args: 193 project_id (str): ID of the Project 194 dataset_id (str): ID of the Dataset 195 download_location (str): Local destination for downloaded files 196 files (typing.List[str]): Optional list of files to download 197 """ 198 if files is None: 199 files = self.get_file_listing(project_id, dataset_id) 200 201 if len(files) == 0: 202 return 203 204 first_file = files[0] 205 if isinstance(first_file, File): 206 files = [file.relative_path for file in files] 207 access_context = first_file.access_context 208 else: 209 dataset = self.get(project_id, dataset_id) 210 access_context = FileAccessContext.download(project_id=project_id, 211 base_url=dataset.s3) 212 213 self._file_service.download_files(access_context, download_location, files)
Service for interacting with the Dataset endpoints
18 def list(self, project_id: str, max_items: int = 10000) -> List[Dataset]: 19 """List datasets 20 21 Retrieves a list of datasets for a given project 22 23 Args: 24 project_id (str): ID of the Project 25 max_items (int): Maximum number of records to get (default 10,000) 26 """ 27 return get_all_records( 28 records_getter=lambda page_args: get_datasets.sync( 29 project_id=project_id, 30 client=self._api_client, 31 next_token=page_args.next_token, 32 limit=page_args.limit 33 ), 34 max_items=max_items 35 )
List datasets
Retrieves a list of datasets for a given project
Arguments:
- project_id (str): ID of the Project
- max_items (int): Maximum number of records to get (default 10,000)
37 def import_public(self, project_id: str, import_request: ImportDataRequest) -> CreateResponse: 38 """ 39 Download data from public repositories 40 41 Args: 42 project_id (str): ID of the Project 43 import_request (cirro_api_client.v1.models.ImportDataRequest): 44 45 Returns: 46 ID of the created dataset 47 """ 48 return import_public_dataset.sync(project_id=project_id, client=self._api_client, body=import_request)
Download data from public repositories
Arguments:
- project_id (str): ID of the Project
- import_request (cirro_api_client.v1.models.ImportDataRequest):
Returns:
ID of the created dataset
50 def create(self, project_id: str, upload_request: UploadDatasetRequest) -> UploadDatasetCreateResponse: 51 """ 52 Registers a dataset in Cirro, which can subsequently have files uploaded to it 53 54 Args: 55 project_id (str): ID of the Project 56 upload_request (cirro_api_client.v1.models.UploadDatasetRequest): 57 58 Returns: 59 ID of the created dataset and the path to upload files 60 61 ```python 62 from cirro_api_client.v1.models import UploadDatasetRequest 63 from cirro.cirro_client import CirroApi 64 65 cirro = CirroApi() 66 request = UploadDatasetRequest( 67 name="Name of new dataset", 68 process_id="paired_dnaseq", 69 expected_files=["read_1.fastq.gz", "read_2.fastq.gz"], 70 description="Description of the dataset" 71 ) 72 cirro.datasets.create("project-id", request) 73 ``` 74 """ 75 return upload_dataset.sync(project_id=project_id, client=self._api_client, body=upload_request)
Registers a dataset in Cirro, which can subsequently have files uploaded to it
Arguments:
- project_id (str): ID of the Project
- upload_request (cirro_api_client.v1.models.UploadDatasetRequest):
Returns:
ID of the created dataset and the path to upload files
from cirro_api_client.v1.models import UploadDatasetRequest
from cirro.cirro_client import CirroApi
cirro = CirroApi()
request = UploadDatasetRequest(
name="Name of new dataset",
process_id="paired_dnaseq",
expected_files=["read_1.fastq.gz", "read_2.fastq.gz"],
description="Description of the dataset"
)
cirro.datasets.create("project-id", request)
77 def get(self, project_id: str, dataset_id: str) -> Optional[DatasetDetail]: 78 """ 79 Gets detailed information about a dataset 80 81 Args: 82 project_id (str): ID of the Project 83 dataset_id (str): ID of the Dataset 84 85 Returns: 86 The dataset, if found 87 """ 88 return get_dataset.sync(project_id=project_id, dataset_id=dataset_id, client=self._api_client)
Gets detailed information about a dataset
Arguments:
- project_id (str): ID of the Project
- dataset_id (str): ID of the Dataset
Returns:
The dataset, if found
90 def update(self, project_id: str, dataset_id: str, request: UpdateDatasetRequest) -> DatasetDetail: 91 """ 92 Update info on a dataset (name, description, and/or tags) 93 94 Args: 95 project_id (str): ID of the Project 96 dataset_id (str): ID of the Dataset 97 request (cirro_api_client.v1.models.UpdateDatasetRequest): 98 99 Returns: 100 The updated dataset 101 102 ```python 103 from cirro_api_client.v1.models import UpdateDatasetRequest 104 from cirro.cirro_client import CirroApi 105 106 cirro = CirroApi() 107 request = UpdateDatasetRequest( 108 name="Name of new dataset", 109 process_id="paired_dnaseq", 110 description="Description of the dataset" 111 ) 112 cirro.datasets.update("project-id", "dataset-id", request) 113 ``` 114 """ 115 return update_dataset.sync(project_id=project_id, dataset_id=dataset_id, body=request, client=self._api_client)
Update info on a dataset (name, description, and/or tags)
Arguments:
- project_id (str): ID of the Project
- dataset_id (str): ID of the Dataset
- request (cirro_api_client.v1.models.UpdateDatasetRequest):
Returns:
The updated dataset
from cirro_api_client.v1.models import UpdateDatasetRequest
from cirro.cirro_client import CirroApi
cirro = CirroApi()
request = UpdateDatasetRequest(
name="Name of new dataset",
process_id="paired_dnaseq",
description="Description of the dataset"
)
cirro.datasets.update("project-id", "dataset-id", request)
117 def delete(self, project_id: str, dataset_id: str) -> None: 118 """ 119 Delete a dataset 120 121 After a dataset has been deleted, the files associated with that 122 dataset are saved according to the project's retention time. 123 124 Args: 125 project_id (str): ID of the Project 126 dataset_id (str): ID of the Dataset 127 """ 128 delete_dataset.sync_detailed(project_id=project_id, dataset_id=dataset_id, client=self._api_client)
Delete a dataset
After a dataset has been deleted, the files associated with that dataset are saved according to the project's retention time.
Arguments:
- project_id (str): ID of the Project
- dataset_id (str): ID of the Dataset
130 def get_file_listing(self, project_id: str, dataset_id: str) -> List[File]: 131 """ 132 Gets a listing of files, charts, and other assets available for the dataset 133 134 Args: 135 project_id (str): ID of the Project 136 dataset_id (str): ID of the Dataset 137 """ 138 manifest = get_dataset_manifest.sync( 139 project_id=project_id, 140 dataset_id=dataset_id, 141 client=self._api_client 142 ) 143 144 files = [ 145 File.from_file_entry( 146 f, 147 project_id=project_id, 148 domain=manifest.domain 149 ) 150 for f in manifest.files 151 ] 152 return files
Gets a listing of files, charts, and other assets available for the dataset
Arguments:
- project_id (str): ID of the Project
- dataset_id (str): ID of the Dataset
154 def upload_files(self, project_id: str, dataset_id: str, local_directory: str, files: List[str]) -> None: 155 """ 156 Uploads files to a given dataset from the specified local directory 157 158 Args: 159 project_id (str): ID of the Project 160 dataset_id (str): ID of the Dataset 161 local_directory (str): Path to local directory 162 files (typing.List[str]): List of relative paths to files within the local directory 163 164 """ 165 dataset = self.get(project_id, dataset_id) 166 167 access_context = FileAccessContext.upload_dataset( 168 project_id=project_id, 169 dataset_id=dataset_id, 170 base_url=dataset.s3 171 ) 172 173 self._file_service.upload_files( 174 access_context, 175 local_directory, 176 files 177 )
Uploads files to a given dataset from the specified local directory
Arguments:
- project_id (str): ID of the Project
- dataset_id (str): ID of the Dataset
- local_directory (str): Path to local directory
- files (typing.List[str]): List of relative paths to files within the local directory
179 def download_files( 180 self, 181 project_id: str, 182 dataset_id: str, 183 download_location: str, 184 files: Union[List[File], List[str]] = None 185 ) -> None: 186 """ 187 Downloads files from a dataset 188 189 The `files` argument is used to optionally specify a subset of files 190 to be downloaded. By default, all files are downloaded. 191 192 Args: 193 project_id (str): ID of the Project 194 dataset_id (str): ID of the Dataset 195 download_location (str): Local destination for downloaded files 196 files (typing.List[str]): Optional list of files to download 197 """ 198 if files is None: 199 files = self.get_file_listing(project_id, dataset_id) 200 201 if len(files) == 0: 202 return 203 204 first_file = files[0] 205 if isinstance(first_file, File): 206 files = [file.relative_path for file in files] 207 access_context = first_file.access_context 208 else: 209 dataset = self.get(project_id, dataset_id) 210 access_context = FileAccessContext.download(project_id=project_id, 211 base_url=dataset.s3) 212 213 self._file_service.download_files(access_context, download_location, files)
Downloads files from a dataset
The files
argument is used to optionally specify a subset of files
to be downloaded. By default, all files are downloaded.
Arguments:
- project_id (str): ID of the Project
- dataset_id (str): ID of the Dataset
- download_location (str): Local destination for downloaded files
- files (typing.List[str]): Optional list of files to download
Inherited Members
- cirro.services.file.FileEnabledService
- FileEnabledService
13class ExecutionService(BaseService): 14 """ 15 Service for interacting with the Execution endpoints 16 """ 17 def run_analysis(self, project_id: str, request: RunAnalysisRequest) -> CreateResponse: 18 """ 19 Launch an analysis job running a process on a set of inputs 20 21 Args: 22 project_id (str): ID of the Project 23 request (cirro_api_client.v1.models.RunAnalysisRequest): 24 25 Returns: 26 The ID of the created dataset 27 28 ```python 29 from cirro_api_client.v1.models import RunAnalysisRequest, RunAnalysisRequestParams 30 from cirro.cirro_client import CirroApi 31 32 # Example: 33 # Run the "process-nf-core-rnaseq-3_8" process using input data 34 # from a dataset with the id "source-dataset-id" 35 36 # Optional analysis parameters 37 params = RunAnalysisRequestParams.from_dict({ 38 "param_a": "val_a", 39 "param_b": "val_b" 40 }) 41 42 cirro = CirroApi() 43 request = RunAnalysisRequest( 44 name="Name of the newly created dataset", 45 description="Longer description of newly created dataset", 46 process_id="process-nf-core-rnaseq-3_8", 47 source_dataset_ids=["source-dataset-id"], 48 params=params 49 ) 50 cirro.execution.run_analysis("project-id", request) 51 ``` 52 """ 53 54 form_spec = get_process_parameters.sync( 55 process_id=request.process_id, 56 client=self._api_client 57 ) 58 59 ParameterSpecification( 60 form_spec 61 ).validate_params( 62 request.params.to_dict() if request.params else {} 63 ) 64 65 return run_analysis.sync( 66 project_id=project_id, 67 body=request, 68 client=self._api_client 69 ) 70 71 def stop_analysis(self, project_id: str, dataset_id: str): 72 """ 73 Terminates all jobs related to a running analysis 74 75 Args: 76 project_id (str): ID of the Project 77 dataset_id (str): ID of the Dataset 78 """ 79 80 return stop_analysis.sync( 81 project_id=project_id, 82 dataset_id=dataset_id, 83 client=self._api_client 84 ) 85 86 def get_project_summary(self, project_id: str) -> GetProjectSummaryResponse200: 87 """ 88 Gets an overview of the executions currently running in the project, by job queue 89 90 Args: 91 project_id (str): ID of the Project 92 93 Returns: 94 `cirro_api_client.v1.models.GetProjectSummaryResponse200` 95 """ 96 97 return get_project_summary.sync( 98 project_id=project_id, 99 client=self._api_client 100 ).additional_properties 101 102 def get_execution_logs(self, project_id: str, dataset_id: str) -> str: 103 """ 104 Gets live logs from main execution task 105 106 Args: 107 project_id (str): ID of the Project 108 dataset_id (str): ID of the Dataset 109 110 """ 111 112 resp = get_execution_logs.sync( 113 project_id=project_id, 114 dataset_id=dataset_id, 115 client=self._api_client 116 ) 117 118 return '\n'.join(e.message for e in resp.events) 119 120 def get_tasks_for_execution(self, project_id: str, dataset_id: str) -> Optional[List[Task]]: 121 """ 122 Gets the tasks submitted by the workflow execution 123 124 Args: 125 project_id (str): ID of the Project 126 dataset_id (str): ID of the Dataset 127 """ 128 129 return get_tasks_for_execution.sync( 130 project_id=project_id, 131 dataset_id=dataset_id, 132 client=self._api_client 133 ) 134 135 def get_task_logs(self, project_id: str, dataset_id: str, task_id: str) -> str: 136 """ 137 Gets the log output from an individual task 138 139 Args: 140 project_id (str): ID of the Project 141 dataset_id (str): ID of the Dataset 142 task_id (str): ID of the task 143 144 """ 145 146 resp = get_task_logs.sync( 147 project_id=project_id, 148 dataset_id=dataset_id, 149 task_id=task_id, 150 client=self._api_client 151 ) 152 153 return '\n'.join(e.message for e in resp.events)
Service for interacting with the Execution endpoints
17 def run_analysis(self, project_id: str, request: RunAnalysisRequest) -> CreateResponse: 18 """ 19 Launch an analysis job running a process on a set of inputs 20 21 Args: 22 project_id (str): ID of the Project 23 request (cirro_api_client.v1.models.RunAnalysisRequest): 24 25 Returns: 26 The ID of the created dataset 27 28 ```python 29 from cirro_api_client.v1.models import RunAnalysisRequest, RunAnalysisRequestParams 30 from cirro.cirro_client import CirroApi 31 32 # Example: 33 # Run the "process-nf-core-rnaseq-3_8" process using input data 34 # from a dataset with the id "source-dataset-id" 35 36 # Optional analysis parameters 37 params = RunAnalysisRequestParams.from_dict({ 38 "param_a": "val_a", 39 "param_b": "val_b" 40 }) 41 42 cirro = CirroApi() 43 request = RunAnalysisRequest( 44 name="Name of the newly created dataset", 45 description="Longer description of newly created dataset", 46 process_id="process-nf-core-rnaseq-3_8", 47 source_dataset_ids=["source-dataset-id"], 48 params=params 49 ) 50 cirro.execution.run_analysis("project-id", request) 51 ``` 52 """ 53 54 form_spec = get_process_parameters.sync( 55 process_id=request.process_id, 56 client=self._api_client 57 ) 58 59 ParameterSpecification( 60 form_spec 61 ).validate_params( 62 request.params.to_dict() if request.params else {} 63 ) 64 65 return run_analysis.sync( 66 project_id=project_id, 67 body=request, 68 client=self._api_client 69 )
Launch an analysis job running a process on a set of inputs
Arguments:
- project_id (str): ID of the Project
- request (cirro_api_client.v1.models.RunAnalysisRequest):
Returns:
The ID of the created dataset
from cirro_api_client.v1.models import RunAnalysisRequest, RunAnalysisRequestParams
from cirro.cirro_client import CirroApi
# Example:
# Run the "process-nf-core-rnaseq-3_8" process using input data
# from a dataset with the id "source-dataset-id"
# Optional analysis parameters
params = RunAnalysisRequestParams.from_dict({
"param_a": "val_a",
"param_b": "val_b"
})
cirro = CirroApi()
request = RunAnalysisRequest(
name="Name of the newly created dataset",
description="Longer description of newly created dataset",
process_id="process-nf-core-rnaseq-3_8",
source_dataset_ids=["source-dataset-id"],
params=params
)
cirro.execution.run_analysis("project-id", request)
71 def stop_analysis(self, project_id: str, dataset_id: str): 72 """ 73 Terminates all jobs related to a running analysis 74 75 Args: 76 project_id (str): ID of the Project 77 dataset_id (str): ID of the Dataset 78 """ 79 80 return stop_analysis.sync( 81 project_id=project_id, 82 dataset_id=dataset_id, 83 client=self._api_client 84 )
Terminates all jobs related to a running analysis
Arguments:
- project_id (str): ID of the Project
- dataset_id (str): ID of the Dataset
86 def get_project_summary(self, project_id: str) -> GetProjectSummaryResponse200: 87 """ 88 Gets an overview of the executions currently running in the project, by job queue 89 90 Args: 91 project_id (str): ID of the Project 92 93 Returns: 94 `cirro_api_client.v1.models.GetProjectSummaryResponse200` 95 """ 96 97 return get_project_summary.sync( 98 project_id=project_id, 99 client=self._api_client 100 ).additional_properties
Gets an overview of the executions currently running in the project, by job queue
Arguments:
- project_id (str): ID of the Project
Returns:
102 def get_execution_logs(self, project_id: str, dataset_id: str) -> str: 103 """ 104 Gets live logs from main execution task 105 106 Args: 107 project_id (str): ID of the Project 108 dataset_id (str): ID of the Dataset 109 110 """ 111 112 resp = get_execution_logs.sync( 113 project_id=project_id, 114 dataset_id=dataset_id, 115 client=self._api_client 116 ) 117 118 return '\n'.join(e.message for e in resp.events)
Gets live logs from main execution task
Arguments:
- project_id (str): ID of the Project
- dataset_id (str): ID of the Dataset
120 def get_tasks_for_execution(self, project_id: str, dataset_id: str) -> Optional[List[Task]]: 121 """ 122 Gets the tasks submitted by the workflow execution 123 124 Args: 125 project_id (str): ID of the Project 126 dataset_id (str): ID of the Dataset 127 """ 128 129 return get_tasks_for_execution.sync( 130 project_id=project_id, 131 dataset_id=dataset_id, 132 client=self._api_client 133 )
Gets the tasks submitted by the workflow execution
Arguments:
- project_id (str): ID of the Project
- dataset_id (str): ID of the Dataset
135 def get_task_logs(self, project_id: str, dataset_id: str, task_id: str) -> str: 136 """ 137 Gets the log output from an individual task 138 139 Args: 140 project_id (str): ID of the Project 141 dataset_id (str): ID of the Dataset 142 task_id (str): ID of the task 143 144 """ 145 146 resp = get_task_logs.sync( 147 project_id=project_id, 148 dataset_id=dataset_id, 149 task_id=task_id, 150 client=self._api_client 151 ) 152 153 return '\n'.join(e.message for e in resp.events)
Gets the log output from an individual task
Arguments:
- project_id (str): ID of the Project
- dataset_id (str): ID of the Dataset
- task_id (str): ID of the task
Inherited Members
- cirro.services.base.BaseService
- BaseService
17class FileService(BaseService): 18 """ 19 Service for interacting with files 20 """ 21 enable_additional_checksum: bool 22 transfer_retries: int 23 _get_token_lock = threading.Lock() 24 _read_token_cache: Dict[str, AWSCredentials] = {} 25 26 def __init__(self, api_client, enable_additional_checksum, transfer_retries): 27 """ 28 Instantiates the file service class 29 """ 30 self._api_client = api_client 31 self.enable_additional_checksum = enable_additional_checksum 32 self.transfer_retries = transfer_retries 33 34 def get_access_credentials(self, access_context: FileAccessContext) -> AWSCredentials: 35 """ 36 Retrieves credentials to access files 37 38 Args: 39 access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate 40 """ 41 access_request = access_context.file_access_request 42 43 if access_request.access_type == AccessType.PROJECT_DOWNLOAD: 44 return self._get_project_read_credentials(access_context) 45 46 else: 47 return generate_project_file_access_token.sync( 48 client=self._api_client, 49 project_id=access_context.project_id, 50 body=access_context.file_access_request 51 ) 52 53 def _get_project_read_credentials(self, access_context: FileAccessContext): 54 """ 55 Retrieves credentials to read project data, this can be cached 56 """ 57 access_request = access_context.file_access_request 58 project_id = access_context.project_id 59 with self._get_token_lock: 60 cached_token = self._read_token_cache.get(project_id) 61 62 if not cached_token or datetime.now(tz=timezone.utc) > cached_token.expiration: 63 new_token = generate_project_file_access_token.sync( 64 client=self._api_client, 65 project_id=project_id, 66 body=access_request 67 ) 68 69 self._read_token_cache[project_id] = new_token 70 71 return self._read_token_cache[project_id] 72 73 def get_file(self, file: File) -> bytes: 74 """ 75 Gets the contents of a file 76 77 Args: 78 file (cirro.models.file.File): 79 80 Returns: 81 The raw bytes of the file 82 """ 83 return self.get_file_from_path(file.access_context, file.relative_path) 84 85 def get_file_from_path(self, access_context: FileAccessContext, file_path: str) -> bytes: 86 """ 87 Gets the contents of a file by providing the path, used internally 88 89 Args: 90 access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate 91 file_path (str): Relative path to file within dataset 92 93 Returns: 94 The raw bytes of the file 95 """ 96 97 s3_client = S3Client( 98 partial(self.get_access_credentials, access_context), 99 self.enable_additional_checksum 100 ) 101 102 full_path = f'{access_context.prefix}/{file_path}'.lstrip('/') 103 104 return s3_client.get_file(access_context.bucket, full_path) 105 106 def create_file(self, access_context: FileAccessContext, key: str, 107 contents: str, content_type: str) -> None: 108 """ 109 Creates a file at the specified path 110 111 Args: 112 access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate 113 key (str): Key of object to create 114 contents (str): Content of object 115 content_type (str): 116 """ 117 118 s3_client = S3Client( 119 partial(self.get_access_credentials, access_context), 120 self.enable_additional_checksum 121 ) 122 123 s3_client.create_object( 124 key=key, 125 contents=contents, 126 content_type=content_type, 127 bucket=access_context.bucket 128 ) 129 130 def upload_files(self, access_context: FileAccessContext, directory: str, files: List[str]) -> None: 131 """ 132 Uploads a list of files from the specified directory 133 134 Args: 135 access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate 136 directory (str): base path to upload from 137 files (List[str]): relative path of files to upload 138 """ 139 140 s3_client = S3Client( 141 partial(self.get_access_credentials, access_context), 142 self.enable_additional_checksum 143 ) 144 145 upload_directory( 146 directory, 147 files, 148 s3_client, 149 access_context.bucket, 150 access_context.prefix, 151 max_retries=self.transfer_retries 152 ) 153 154 def download_files(self, access_context: FileAccessContext, directory: str, files: List[str]) -> None: 155 """ 156 Download a list of files to the specified directory 157 158 Args: 159 access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate 160 directory (str): download location 161 files (List[str]): relative path of files to download 162 """ 163 s3_client = S3Client( 164 partial(self.get_access_credentials, access_context), 165 self.enable_additional_checksum 166 ) 167 168 download_directory( 169 directory, 170 files, 171 s3_client, 172 access_context.bucket, 173 access_context.prefix 174 )
Service for interacting with files
26 def __init__(self, api_client, enable_additional_checksum, transfer_retries): 27 """ 28 Instantiates the file service class 29 """ 30 self._api_client = api_client 31 self.enable_additional_checksum = enable_additional_checksum 32 self.transfer_retries = transfer_retries
Instantiates the file service class
34 def get_access_credentials(self, access_context: FileAccessContext) -> AWSCredentials: 35 """ 36 Retrieves credentials to access files 37 38 Args: 39 access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate 40 """ 41 access_request = access_context.file_access_request 42 43 if access_request.access_type == AccessType.PROJECT_DOWNLOAD: 44 return self._get_project_read_credentials(access_context) 45 46 else: 47 return generate_project_file_access_token.sync( 48 client=self._api_client, 49 project_id=access_context.project_id, 50 body=access_context.file_access_request 51 )
Retrieves credentials to access files
Arguments:
- access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate
73 def get_file(self, file: File) -> bytes: 74 """ 75 Gets the contents of a file 76 77 Args: 78 file (cirro.models.file.File): 79 80 Returns: 81 The raw bytes of the file 82 """ 83 return self.get_file_from_path(file.access_context, file.relative_path)
Gets the contents of a file
Arguments:
- file (cirro.models.file.File):
Returns:
The raw bytes of the file
85 def get_file_from_path(self, access_context: FileAccessContext, file_path: str) -> bytes: 86 """ 87 Gets the contents of a file by providing the path, used internally 88 89 Args: 90 access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate 91 file_path (str): Relative path to file within dataset 92 93 Returns: 94 The raw bytes of the file 95 """ 96 97 s3_client = S3Client( 98 partial(self.get_access_credentials, access_context), 99 self.enable_additional_checksum 100 ) 101 102 full_path = f'{access_context.prefix}/{file_path}'.lstrip('/') 103 104 return s3_client.get_file(access_context.bucket, full_path)
Gets the contents of a file by providing the path, used internally
Arguments:
- access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate
- file_path (str): Relative path to file within dataset
Returns:
The raw bytes of the file
106 def create_file(self, access_context: FileAccessContext, key: str, 107 contents: str, content_type: str) -> None: 108 """ 109 Creates a file at the specified path 110 111 Args: 112 access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate 113 key (str): Key of object to create 114 contents (str): Content of object 115 content_type (str): 116 """ 117 118 s3_client = S3Client( 119 partial(self.get_access_credentials, access_context), 120 self.enable_additional_checksum 121 ) 122 123 s3_client.create_object( 124 key=key, 125 contents=contents, 126 content_type=content_type, 127 bucket=access_context.bucket 128 )
Creates a file at the specified path
Arguments:
- access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate
- key (str): Key of object to create
- contents (str): Content of object
- content_type (str):
130 def upload_files(self, access_context: FileAccessContext, directory: str, files: List[str]) -> None: 131 """ 132 Uploads a list of files from the specified directory 133 134 Args: 135 access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate 136 directory (str): base path to upload from 137 files (List[str]): relative path of files to upload 138 """ 139 140 s3_client = S3Client( 141 partial(self.get_access_credentials, access_context), 142 self.enable_additional_checksum 143 ) 144 145 upload_directory( 146 directory, 147 files, 148 s3_client, 149 access_context.bucket, 150 access_context.prefix, 151 max_retries=self.transfer_retries 152 )
Uploads a list of files from the specified directory
Arguments:
- access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate
- directory (str): base path to upload from
- files (List[str]): relative path of files to upload
154 def download_files(self, access_context: FileAccessContext, directory: str, files: List[str]) -> None: 155 """ 156 Download a list of files to the specified directory 157 158 Args: 159 access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate 160 directory (str): download location 161 files (List[str]): relative path of files to download 162 """ 163 s3_client = S3Client( 164 partial(self.get_access_credentials, access_context), 165 self.enable_additional_checksum 166 ) 167 168 download_directory( 169 directory, 170 files, 171 s3_client, 172 access_context.bucket, 173 access_context.prefix 174 )
Download a list of files to the specified directory
Arguments:
- access_context (cirro.models.file.FileAccessContext): File access context, use class methods to generate
- directory (str): download location
- files (List[str]): relative path of files to download
11class MetadataService(BaseService): 12 """ 13 Service for interacting with the Metadata endpoints 14 """ 15 def get_project_samples(self, project_id: str, max_items: int = 10000) -> List[Sample]: 16 """ 17 Retrieves a list of samples associated with a project along with their metadata 18 19 Args: 20 project_id (str): ID of the Project 21 max_items (int): Maximum number of records to get (default 10,000) 22 """ 23 return get_all_records( 24 records_getter=lambda page_args: get_project_samples.sync(project_id=project_id, 25 client=self._api_client, 26 next_token=page_args.next_token, 27 limit=page_args.limit), 28 max_items=max_items 29 ) 30 31 def get_project_schema(self, project_id: str) -> FormSchema: 32 """ 33 Get project metadata schema 34 35 Args: 36 project_id (str): ID of the Project 37 """ 38 return get_project_schema.sync(project_id=project_id, client=self._api_client) 39 40 def update_project_schema(self, project_id: str, schema: FormSchema): 41 """ 42 Update project metadata schema 43 44 Args: 45 project_id (str): ID of the Project 46 schema (cirro_api_client.v1.models.FormSchema): Metadata schema 47 """ 48 update_project_schema.sync_detailed(project_id=project_id, body=schema, client=self._api_client) 49 50 def update_sample(self, project_id: str, sample_id: str, sample: SampleRequest) -> Sample: 51 """ 52 Updates metadata information for sample 53 54 Args: 55 project_id (str): ID of the Project 56 sample_id (str): ID of the sample 57 sample (cirro_api_client.v1.models.SampleRequest): Metadata information for the sample 58 """ 59 return update_sample.sync( 60 project_id=project_id, 61 sample_id=sample_id, 62 body=sample, 63 client=self._api_client 64 )
Service for interacting with the Metadata endpoints
15 def get_project_samples(self, project_id: str, max_items: int = 10000) -> List[Sample]: 16 """ 17 Retrieves a list of samples associated with a project along with their metadata 18 19 Args: 20 project_id (str): ID of the Project 21 max_items (int): Maximum number of records to get (default 10,000) 22 """ 23 return get_all_records( 24 records_getter=lambda page_args: get_project_samples.sync(project_id=project_id, 25 client=self._api_client, 26 next_token=page_args.next_token, 27 limit=page_args.limit), 28 max_items=max_items 29 )
Retrieves a list of samples associated with a project along with their metadata
Arguments:
- project_id (str): ID of the Project
- max_items (int): Maximum number of records to get (default 10,000)
31 def get_project_schema(self, project_id: str) -> FormSchema: 32 """ 33 Get project metadata schema 34 35 Args: 36 project_id (str): ID of the Project 37 """ 38 return get_project_schema.sync(project_id=project_id, client=self._api_client)
Get project metadata schema
Arguments:
- project_id (str): ID of the Project
40 def update_project_schema(self, project_id: str, schema: FormSchema): 41 """ 42 Update project metadata schema 43 44 Args: 45 project_id (str): ID of the Project 46 schema (cirro_api_client.v1.models.FormSchema): Metadata schema 47 """ 48 update_project_schema.sync_detailed(project_id=project_id, body=schema, client=self._api_client)
Update project metadata schema
Arguments:
- project_id (str): ID of the Project
- schema (cirro_api_client.v1.models.FormSchema): Metadata schema
50 def update_sample(self, project_id: str, sample_id: str, sample: SampleRequest) -> Sample: 51 """ 52 Updates metadata information for sample 53 54 Args: 55 project_id (str): ID of the Project 56 sample_id (str): ID of the sample 57 sample (cirro_api_client.v1.models.SampleRequest): Metadata information for the sample 58 """ 59 return update_sample.sync( 60 project_id=project_id, 61 sample_id=sample_id, 62 body=sample, 63 client=self._api_client 64 )
Updates metadata information for sample
Arguments:
- project_id (str): ID of the Project
- sample_id (str): ID of the sample
- sample (cirro_api_client.v1.models.SampleRequest): Metadata information for the sample
Inherited Members
- cirro.services.base.BaseService
- BaseService
10class MetricsService(BaseService): 11 """ 12 Service for interacting with the Metrics endpoints 13 """ 14 def get_for_project(self, project_id: str) -> ProjectMetrics: 15 """ 16 Retrieves the cost and storage metrics for a project. 17 18 Args: 19 project_id (str): ID of the Project 20 """ 21 return get_project_metrics.sync( 22 project_id=project_id, 23 client=self._api_client 24 ) 25 26 def get_all_metrics(self) -> List[ProjectMetrics]: 27 """ 28 Retrieves all available metrics 29 """ 30 return get_all_metrics.sync(client=self._api_client)
Service for interacting with the Metrics endpoints
14 def get_for_project(self, project_id: str) -> ProjectMetrics: 15 """ 16 Retrieves the cost and storage metrics for a project. 17 18 Args: 19 project_id (str): ID of the Project 20 """ 21 return get_project_metrics.sync( 22 project_id=project_id, 23 client=self._api_client 24 )
Retrieves the cost and storage metrics for a project.
Arguments:
- project_id (str): ID of the Project
26 def get_all_metrics(self) -> List[ProjectMetrics]: 27 """ 28 Retrieves all available metrics 29 """ 30 return get_all_metrics.sync(client=self._api_client)
Retrieves all available metrics
Inherited Members
- cirro.services.base.BaseService
- BaseService
13class ProcessService(BaseService): 14 """ 15 Service for interacting with the Process endpoints 16 """ 17 def list(self, process_type: Executor = None) -> List[Process]: 18 """ 19 Retrieves a list of available processes 20 21 Args: 22 process_type (`cirro_api_client.v1.models.Executor`): Optional process type (INGEST, CROMWELL, or NEXTFLOW) 23 """ 24 processes = get_processes.sync(client=self._api_client) 25 return [p for p in processes if not process_type or process_type == p.executor] 26 27 def get(self, process_id: str) -> ProcessDetail: 28 """ 29 Retrieves detailed information on a process 30 31 Args: 32 process_id (str): Process ID 33 """ 34 return get_process.sync(process_id=process_id, client=self._api_client) 35 36 def find_by_name(self, name: str) -> Optional[ProcessDetail]: 37 """ 38 Get a process by its display name 39 40 Args: 41 name (str): Process name 42 """ 43 matched_process = next((p for p in self.list() if p.name == name), None) 44 if not matched_process: 45 return None 46 47 return self.get(matched_process.id) 48 49 def get_parameter_spec(self, process_id: str) -> ParameterSpecification: 50 """ 51 Gets a specification used to describe the parameters used in the process 52 53 Args: 54 process_id (str): Process ID 55 """ 56 form_spec = get_process_parameters.sync(process_id=process_id, client=self._api_client) 57 return ParameterSpecification(form_spec) 58 59 def check_dataset_files(self, files: List[str], process_id: str, directory: str): 60 """ 61 Checks if the file mapping rules for a process are met by the list of files 62 63 Error will be raised if the file mapping rules for the process are not met. 64 No value is returned and no error is raised if the rules are satisfied. 65 66 Args: 67 process_id (str): ID for the process containing the file mapping rules 68 directory: path to directory containing files 69 files (List[str]): File names to check 70 """ 71 # Parse sample sheet file if present 72 sample_sheet = None 73 sample_sheet_file = Path(directory, 'samplesheet.csv') 74 if sample_sheet_file.exists(): 75 sample_sheet = sample_sheet_file.read_text() 76 77 request = ValidateFileRequirementsRequest( 78 file_names=files, 79 sample_sheet=sample_sheet 80 ) 81 requirements = validate_file_requirements.sync(process_id=process_id, body=request, client=self._api_client) 82 83 # These will be sample sheet errors or no files errors 84 if error_msg := requirements.error_msg: 85 raise ValueError(error_msg) 86 87 # These will be errors for missing files 88 all_errors = [ 89 entry.error_msg for entry in requirements.allowed_data_types 90 if entry.error_msg is not None 91 ] 92 patterns = [ 93 ' or '.join([ 94 e.example_name 95 for e in entry.allowed_patterns 96 ]) 97 for entry in requirements.allowed_data_types 98 ] 99 100 if len(all_errors) != 0: 101 raise ValueError("Files do not meet dataset type requirements. The expected files are: \n" + 102 "\n".join(patterns))
Service for interacting with the Process endpoints
17 def list(self, process_type: Executor = None) -> List[Process]: 18 """ 19 Retrieves a list of available processes 20 21 Args: 22 process_type (`cirro_api_client.v1.models.Executor`): Optional process type (INGEST, CROMWELL, or NEXTFLOW) 23 """ 24 processes = get_processes.sync(client=self._api_client) 25 return [p for p in processes if not process_type or process_type == p.executor]
Retrieves a list of available processes
Arguments:
- process_type (
cirro_api_client.v1.models.Executor
): Optional process type (INGEST, CROMWELL, or NEXTFLOW)
27 def get(self, process_id: str) -> ProcessDetail: 28 """ 29 Retrieves detailed information on a process 30 31 Args: 32 process_id (str): Process ID 33 """ 34 return get_process.sync(process_id=process_id, client=self._api_client)
Retrieves detailed information on a process
Arguments:
- process_id (str): Process ID
36 def find_by_name(self, name: str) -> Optional[ProcessDetail]: 37 """ 38 Get a process by its display name 39 40 Args: 41 name (str): Process name 42 """ 43 matched_process = next((p for p in self.list() if p.name == name), None) 44 if not matched_process: 45 return None 46 47 return self.get(matched_process.id)
Get a process by its display name
Arguments:
- name (str): Process name
49 def get_parameter_spec(self, process_id: str) -> ParameterSpecification: 50 """ 51 Gets a specification used to describe the parameters used in the process 52 53 Args: 54 process_id (str): Process ID 55 """ 56 form_spec = get_process_parameters.sync(process_id=process_id, client=self._api_client) 57 return ParameterSpecification(form_spec)
Gets a specification used to describe the parameters used in the process
Arguments:
- process_id (str): Process ID
59 def check_dataset_files(self, files: List[str], process_id: str, directory: str): 60 """ 61 Checks if the file mapping rules for a process are met by the list of files 62 63 Error will be raised if the file mapping rules for the process are not met. 64 No value is returned and no error is raised if the rules are satisfied. 65 66 Args: 67 process_id (str): ID for the process containing the file mapping rules 68 directory: path to directory containing files 69 files (List[str]): File names to check 70 """ 71 # Parse sample sheet file if present 72 sample_sheet = None 73 sample_sheet_file = Path(directory, 'samplesheet.csv') 74 if sample_sheet_file.exists(): 75 sample_sheet = sample_sheet_file.read_text() 76 77 request = ValidateFileRequirementsRequest( 78 file_names=files, 79 sample_sheet=sample_sheet 80 ) 81 requirements = validate_file_requirements.sync(process_id=process_id, body=request, client=self._api_client) 82 83 # These will be sample sheet errors or no files errors 84 if error_msg := requirements.error_msg: 85 raise ValueError(error_msg) 86 87 # These will be errors for missing files 88 all_errors = [ 89 entry.error_msg for entry in requirements.allowed_data_types 90 if entry.error_msg is not None 91 ] 92 patterns = [ 93 ' or '.join([ 94 e.example_name 95 for e in entry.allowed_patterns 96 ]) 97 for entry in requirements.allowed_data_types 98 ] 99 100 if len(all_errors) != 0: 101 raise ValueError("Files do not meet dataset type requirements. The expected files are: \n" + 102 "\n".join(patterns))
Checks if the file mapping rules for a process are met by the list of files
Error will be raised if the file mapping rules for the process are not met. No value is returned and no error is raised if the rules are satisfied.
Arguments:
- process_id (str): ID for the process containing the file mapping rules
- directory: path to directory containing files
- files (List[str]): File names to check
Inherited Members
- cirro.services.base.BaseService
- BaseService
12class ProjectService(BaseService): 13 """ 14 Service for interacting with the Project endpoints 15 """ 16 def list(self): 17 """ 18 Retrieve a list of projects 19 """ 20 return get_projects.sync(client=self._api_client) 21 22 def get(self, project_id: str) -> ProjectDetail: 23 """ 24 Get detailed project information 25 26 Args: 27 project_id (str): Project ID 28 """ 29 return get_project.sync(project_id=project_id, client=self._api_client) 30 31 def create(self, request: ProjectRequest) -> CreateResponse: 32 """ 33 Create a project 34 35 Args: 36 request (`cirro_api_client.v1.models.ProjectRequest`): Detailed information about the project to create 37 38 Examples: 39 ```python 40 from cirro_api_client.v1.models import ProjectRequest, ProjectSettings, Contact, BudgetPeriod, CloudAccount, \ 41 CloudAccountType 42 from cirro.cirro_client import CirroApi 43 44 cirro = CirroApi() 45 46 # Bring your own account projects are hosted by the user 47 # You must provide the account details and VPC information 48 # Please view the ProjectSettings model for more information on the attributes required 49 byoa_project = ProjectRequest( 50 name="New Project Name", 51 description="Description of new project", 52 billing_account_id="billing-account-id", 53 settings=ProjectSettings( 54 budget_period=BudgetPeriod.MONTHLY, 55 budget_amount=1000, 56 max_spot_vcpu=300, 57 service_connections=[], 58 retention_policy_days=7, 59 vpc_id="vpc-000000000000", 60 batch_subnets=["subnet-000000000000", "subnet-000000000001"], 61 sagemaker_subnets=["subnet-000000000000", "subnet-000000000001"], 62 kms_arn="arn:aws:kms:us-west-2:000000000000:key/00000000-0000-0000-0000-000000000000" 63 ), 64 account=CloudAccount( 65 account_id="<AWS_ACCOUNT_ID>", 66 region_name="us-west-2", 67 account_name="Cirro Lab Project", 68 account_type=CloudAccountType.BYOA 69 ), 70 contacts=[ 71 Contact( 72 name="Contact Name", 73 organization="Contact Organization", 74 email="contact@email.com", 75 phone="987-654-3210" 76 ) 77 ] 78 ) 79 80 # Hosted projects are managed by Cirro 81 hosted_project = ProjectRequest( 82 name="New Project Name", 83 description="Description of new project", 84 billing_account_id="billing-account-id", 85 settings=ProjectSettings( 86 budget_period=BudgetPeriod.MONTHLY, 87 budget_amount=1000, 88 max_spot_vcpu=300, 89 service_connections=[], 90 retention_policy_days=7 91 ), 92 contacts=[ 93 Contact( 94 name="Contact Name", 95 organization="Contact Organization", 96 email="contact@email.com", 97 phone="987-654-3210" 98 ) 99 ] 100 ) 101 102 cirro.projects.create(byoa_project) 103 ``` 104 """ 105 return create_project.sync(client=self._api_client, body=request) 106 107 def update(self, project_id: str, request: ProjectRequest) -> ProjectDetail: 108 """ 109 Updates a project 110 111 Args: 112 project_id (str): ID of project to update 113 request (`cirro_api_client.v1.models.ProjectRequest`): New details for the project 114 """ 115 return update_project.sync(project_id=project_id, body=request, client=self._api_client) 116 117 def update_tags(self, project_id: str, tags: List[Tag]): 118 """ 119 Sets tags on a project 120 121 Args: 122 project_id (str): Project ID 123 tags (List[Tag]): List of tags to apply 124 """ 125 update_project_tags.sync_detailed(project_id=project_id, body=tags, client=self._api_client) 126 127 def get_users(self, project_id: str) -> Optional[List[ProjectUser]]: 128 """ 129 Gets users who have access to the project 130 131 Args: 132 project_id (str): Project ID 133 """ 134 return get_project_users.sync(project_id=project_id, client=self._api_client) 135 136 def set_user_role(self, project_id: str, username: str, role: ProjectRole, supress_notification=False): 137 """ 138 Sets a user's role within a project. 139 140 Set to `ProjectRole.NONE` if removing the user from a project. 141 142 Args: 143 project_id (str): Project ID 144 username (str): Username 145 role (`cirro_api_client.v1.models.ProjectRole`): New role to apply 146 supress_notification (bool): Suppress email notification 147 """ 148 request_body = SetUserProjectRoleRequest( 149 username=username, 150 role=role, 151 supress_notification=supress_notification 152 ) 153 set_user_project_role.sync_detailed(project_id=project_id, body=request_body, client=self._api_client)
Service for interacting with the Project endpoints
16 def list(self): 17 """ 18 Retrieve a list of projects 19 """ 20 return get_projects.sync(client=self._api_client)
Retrieve a list of projects
22 def get(self, project_id: str) -> ProjectDetail: 23 """ 24 Get detailed project information 25 26 Args: 27 project_id (str): Project ID 28 """ 29 return get_project.sync(project_id=project_id, client=self._api_client)
Get detailed project information
Arguments:
- project_id (str): Project ID
31 def create(self, request: ProjectRequest) -> CreateResponse: 32 """ 33 Create a project 34 35 Args: 36 request (`cirro_api_client.v1.models.ProjectRequest`): Detailed information about the project to create 37 38 Examples: 39 ```python 40 from cirro_api_client.v1.models import ProjectRequest, ProjectSettings, Contact, BudgetPeriod, CloudAccount, \ 41 CloudAccountType 42 from cirro.cirro_client import CirroApi 43 44 cirro = CirroApi() 45 46 # Bring your own account projects are hosted by the user 47 # You must provide the account details and VPC information 48 # Please view the ProjectSettings model for more information on the attributes required 49 byoa_project = ProjectRequest( 50 name="New Project Name", 51 description="Description of new project", 52 billing_account_id="billing-account-id", 53 settings=ProjectSettings( 54 budget_period=BudgetPeriod.MONTHLY, 55 budget_amount=1000, 56 max_spot_vcpu=300, 57 service_connections=[], 58 retention_policy_days=7, 59 vpc_id="vpc-000000000000", 60 batch_subnets=["subnet-000000000000", "subnet-000000000001"], 61 sagemaker_subnets=["subnet-000000000000", "subnet-000000000001"], 62 kms_arn="arn:aws:kms:us-west-2:000000000000:key/00000000-0000-0000-0000-000000000000" 63 ), 64 account=CloudAccount( 65 account_id="<AWS_ACCOUNT_ID>", 66 region_name="us-west-2", 67 account_name="Cirro Lab Project", 68 account_type=CloudAccountType.BYOA 69 ), 70 contacts=[ 71 Contact( 72 name="Contact Name", 73 organization="Contact Organization", 74 email="contact@email.com", 75 phone="987-654-3210" 76 ) 77 ] 78 ) 79 80 # Hosted projects are managed by Cirro 81 hosted_project = ProjectRequest( 82 name="New Project Name", 83 description="Description of new project", 84 billing_account_id="billing-account-id", 85 settings=ProjectSettings( 86 budget_period=BudgetPeriod.MONTHLY, 87 budget_amount=1000, 88 max_spot_vcpu=300, 89 service_connections=[], 90 retention_policy_days=7 91 ), 92 contacts=[ 93 Contact( 94 name="Contact Name", 95 organization="Contact Organization", 96 email="contact@email.com", 97 phone="987-654-3210" 98 ) 99 ] 100 ) 101 102 cirro.projects.create(byoa_project) 103 ``` 104 """ 105 return create_project.sync(client=self._api_client, body=request)
Create a project
Arguments:
- request (
cirro_api_client.v1.models.ProjectRequest
): Detailed information about the project to create
Examples:
from cirro_api_client.v1.models import ProjectRequest, ProjectSettings, Contact, BudgetPeriod, CloudAccount, CloudAccountType
from cirro.cirro_client import CirroApi
cirro = CirroApi()
# Bring your own account projects are hosted by the user
# You must provide the account details and VPC information
# Please view the ProjectSettings model for more information on the attributes required
byoa_project = ProjectRequest(
name="New Project Name",
description="Description of new project",
billing_account_id="billing-account-id",
settings=ProjectSettings(
budget_period=BudgetPeriod.MONTHLY,
budget_amount=1000,
max_spot_vcpu=300,
service_connections=[],
retention_policy_days=7,
vpc_id="vpc-000000000000",
batch_subnets=["subnet-000000000000", "subnet-000000000001"],
sagemaker_subnets=["subnet-000000000000", "subnet-000000000001"],
kms_arn="arn:aws:kms:us-west-2:000000000000:key/00000000-0000-0000-0000-000000000000"
),
account=CloudAccount(
account_id="<AWS_ACCOUNT_ID>",
region_name="us-west-2",
account_name="Cirro Lab Project",
account_type=CloudAccountType.BYOA
),
contacts=[
Contact(
name="Contact Name",
organization="Contact Organization",
email="contact@email.com",
phone="987-654-3210"
)
]
)
# Hosted projects are managed by Cirro
hosted_project = ProjectRequest(
name="New Project Name",
description="Description of new project",
billing_account_id="billing-account-id",
settings=ProjectSettings(
budget_period=BudgetPeriod.MONTHLY,
budget_amount=1000,
max_spot_vcpu=300,
service_connections=[],
retention_policy_days=7
),
contacts=[
Contact(
name="Contact Name",
organization="Contact Organization",
email="contact@email.com",
phone="987-654-3210"
)
]
)
cirro.projects.create(byoa_project)
107 def update(self, project_id: str, request: ProjectRequest) -> ProjectDetail: 108 """ 109 Updates a project 110 111 Args: 112 project_id (str): ID of project to update 113 request (`cirro_api_client.v1.models.ProjectRequest`): New details for the project 114 """ 115 return update_project.sync(project_id=project_id, body=request, client=self._api_client)
Updates a project
Arguments:
- project_id (str): ID of project to update
- request (
cirro_api_client.v1.models.ProjectRequest
): New details for the project
127 def get_users(self, project_id: str) -> Optional[List[ProjectUser]]: 128 """ 129 Gets users who have access to the project 130 131 Args: 132 project_id (str): Project ID 133 """ 134 return get_project_users.sync(project_id=project_id, client=self._api_client)
Gets users who have access to the project
Arguments:
- project_id (str): Project ID
136 def set_user_role(self, project_id: str, username: str, role: ProjectRole, supress_notification=False): 137 """ 138 Sets a user's role within a project. 139 140 Set to `ProjectRole.NONE` if removing the user from a project. 141 142 Args: 143 project_id (str): Project ID 144 username (str): Username 145 role (`cirro_api_client.v1.models.ProjectRole`): New role to apply 146 supress_notification (bool): Suppress email notification 147 """ 148 request_body = SetUserProjectRoleRequest( 149 username=username, 150 role=role, 151 supress_notification=supress_notification 152 ) 153 set_user_project_role.sync_detailed(project_id=project_id, body=request_body, client=self._api_client)
Sets a user's role within a project.
Set to ProjectRole.NONE
if removing the user from a project.
Arguments:
- project_id (str): Project ID
- username (str): Username
- role (
cirro_api_client.v1.models.ProjectRole
): New role to apply - supress_notification (bool): Suppress email notification
Inherited Members
- cirro.services.base.BaseService
- BaseService
10class ReferenceService(BaseService): 11 """ 12 Service for interacting with the References endpoints 13 """ 14 def get_types(self) -> Optional[List[ReferenceType]]: 15 """ 16 List available reference types 17 """ 18 return get_reference_types.sync(client=self._api_client) 19 20 def get_for_project(self, project_id: str) -> Optional[List[Reference]]: 21 """ 22 List available references for a given project 23 """ 24 return get_references_for_project.sync(project_id=project_id, client=self._api_client)
Service for interacting with the References endpoints
14 def get_types(self) -> Optional[List[ReferenceType]]: 15 """ 16 List available reference types 17 """ 18 return get_reference_types.sync(client=self._api_client)
List available reference types
20 def get_for_project(self, project_id: str) -> Optional[List[Reference]]: 21 """ 22 List available references for a given project 23 """ 24 return get_references_for_project.sync(project_id=project_id, client=self._api_client)
List available references for a given project
Inherited Members
- cirro.services.base.BaseService
- BaseService