Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Test install
run: |
poetry install --all-extras
poetry run cirro
poetry run cirro --help

- name: Build python package
run: |
Expand Down
13 changes: 10 additions & 3 deletions cirro/sdk/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from time import sleep
from typing import List, Union

from cirro_api_client.v1.models import Project, UploadDatasetRequest, Dataset, Sample
from cirro_api_client.v1.models import Project, UploadDatasetRequest, Dataset, Sample, Tag

from cirro.cirro_client import CirroApi
from cirro.file_utils import get_files_in_directory
Expand Down Expand Up @@ -145,7 +145,8 @@ def upload_dataset(
description='',
process: Union[DataPortalProcess, str] = None,
upload_folder: str = None,
files: list = None
files: List[str] = None,
tags: List[str] = None,
):
"""
Upload a set of files to the Data Portal, creating a new dataset.
Expand All @@ -158,6 +159,7 @@ def upload_dataset(
process (str | DataPortalProcess): Process to run may be referenced by name, ID, or object
upload_folder (str): Folder containing files to upload
files (List[str]): Optional subset of files to upload from the folder
tags (List[str]): Optional list of tags to apply to the dataset
"""

if name is None:
Expand All @@ -178,6 +180,10 @@ def upload_dataset(
if files is None or len(files) == 0:
raise RuntimeWarning("No files to upload, exiting")

# Normalize into Tag object
if tags is not None:
tags = [Tag(value=value) for value in tags]

# Make sure that the files match the expected pattern
self._client.processes.check_dataset_files(files, process.id, upload_folder)

Expand All @@ -186,7 +192,8 @@ def upload_dataset(
process_id=process.id,
name=name,
description=description,
expected_files=files
expected_files=files,
tags=tags,
)

# Get the response
Expand Down
19 changes: 17 additions & 2 deletions cirro/services/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@ def import_public(self, project_id: str, import_request: ImportDataRequest) -> C

Returns:
ID of the created dataset

```python
from cirro_api_client.v1.models import ImportDataRequest, Tag
from cirro.cirro_client import CirroApi

cirro = CirroApi()
request = ImportDataRequest(
name="Imported dataset",
description="Description of the dataset",
public_ids=["SRR123456", "SRR123457"],
tags=[Tag(value="tag1")]
)
cirro.datasets.import_public("project-id", request)
```
"""
return import_public_dataset.sync(project_id=project_id, client=self._api_client, body=import_request)

Expand All @@ -93,15 +107,16 @@ def create(self, project_id: str, upload_request: UploadDatasetRequest) -> Uploa
ID of the created dataset and the path to upload files

```python
from cirro_api_client.v1.models import UploadDatasetRequest
from cirro_api_client.v1.models import UploadDatasetRequest, Tag
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"
description="Description of the dataset",
tags=[Tag(value="tag1"), Tag(value="tag2")]
)
cirro.datasets.create("project-id", request)
```
Expand Down
Loading
Loading