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
8 changes: 3 additions & 5 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write

steps:
- uses: actions/checkout@v2
Expand All @@ -39,9 +40,6 @@ jobs:
run: |
poetry build

- name: Publish python package
- name: Publish package distributions to PyPI
if: github.event_name == 'release'
run: |
poetry publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_API_TOKEN }}
uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b
4 changes: 2 additions & 2 deletions cirro/file_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_files_in_directory(
return paths


def _bytes_to_human_readable(num_bytes: int) -> str:
def bytes_to_human_readable(num_bytes: int) -> str:
for unit in ['B', 'KB', 'MB', 'GB', 'TB', 'PB']:
if num_bytes < 1000.0 or unit == 'PB':
break
Expand All @@ -118,7 +118,7 @@ def get_files_stats(files: List[PathLike]) -> DirectoryStatistics:
sizes = [f.stat().st_size for f in files]
total_size = sum(sizes)
return DirectoryStatistics(
size_friendly=_bytes_to_human_readable(total_size),
size_friendly=bytes_to_human_readable(total_size),
size=total_size,
number_of_files=len(sizes)
)
Expand Down
14 changes: 13 additions & 1 deletion cirro/sdk/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
RunAnalysisRequestParams, Tag, ArtifactType, NamedItem, ValidateFileRequirementsRequest

from cirro.cirro_client import CirroApi
from cirro.file_utils import filter_files_by_pattern
from cirro.file_utils import bytes_to_human_readable, filter_files_by_pattern
from cirro.models.assets import DatasetAssets
from cirro.models.file import PathLike
from cirro.sdk.asset import DataPortalAssets, DataPortalAsset
Expand Down Expand Up @@ -219,6 +219,18 @@ def share(self) -> Optional[NamedItem]:
"""
return self._get_detail().share

@property
def file_count(self) -> int:
return self._get_detail().file_count

@property
def total_size_bytes(self) -> int:
return self._get_detail().total_size_bytes

@property
def total_size(self) -> str:
return bytes_to_human_readable(self.total_size_bytes)

@property
def created_by(self) -> str:
"""User who created the dataset"""
Expand Down
Loading
Loading