cloudos-cli 2.26.1__tar.gz → 2.27.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/PKG-INFO +11 -1
  2. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/README.md +10 -0
  3. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/__main__.py +71 -49
  4. cloudos_cli-2.27.0/cloudos_cli/_version.py +1 -0
  5. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/datasets/datasets.py +7 -1
  6. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/utils/__init__.py +2 -2
  7. cloudos_cli-2.27.0/cloudos_cli/utils/resources.py +46 -0
  8. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli.egg-info/PKG-INFO +11 -1
  9. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli.egg-info/SOURCES.txt +1 -0
  10. cloudos_cli-2.26.1/cloudos_cli/_version.py +0 -1
  11. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/LICENSE +0 -0
  12. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/__init__.py +0 -0
  13. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/clos.py +0 -0
  14. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/configure/__init__.py +0 -0
  15. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/configure/configure.py +0 -0
  16. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/datasets/__init__.py +0 -0
  17. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/import_wf/__init__.py +0 -0
  18. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/import_wf/import_wf.py +0 -0
  19. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/jobs/__init__.py +0 -0
  20. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/jobs/job.py +0 -0
  21. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/queue/__init__.py +0 -0
  22. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/queue/queue.py +0 -0
  23. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/utils/errors.py +0 -0
  24. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli/utils/requests.py +0 -0
  25. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli.egg-info/dependency_links.txt +0 -0
  26. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli.egg-info/entry_points.txt +0 -0
  27. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli.egg-info/requires.txt +0 -0
  28. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/cloudos_cli.egg-info/top_level.txt +0 -0
  29. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/setup.cfg +0 -0
  30. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/setup.py +0 -0
  31. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/tests/__init__.py +0 -0
  32. {cloudos_cli-2.26.1 → cloudos_cli-2.27.0}/tests/functions_for_pytest.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudos_cli
3
- Version: 2.26.1
3
+ Version: 2.27.0
4
4
  Summary: Python package for interacting with CloudOS
5
5
  Home-page: https://github.com/lifebit-ai/cloudos-cli
6
6
  Author: David Piñeyro
@@ -758,9 +758,19 @@ cloudos datasets ls <path> \
758
758
  --workspace-id $WORKSPACE_ID \
759
759
  --project-name $PROJEC_NAME
760
760
  ```
761
+
762
+
761
763
  The output of this command is a list of files and folders present in the specified project.
762
764
  If the `<path>` is left empty, the command will return the list of folders present in the selected project.
763
765
 
766
+ If you require more information on the files and folder listed, you can use the `--details` flag that will output a table containing the following columns:
767
+ - Type (folder or file)
768
+ - Owner
769
+ - Size in human readable format
770
+ - Last updated
771
+ - Filepath (the file or folder name)
772
+ - S3 Path
773
+
764
774
  ### WDL pipeline support
765
775
 
766
776
  #### Cromwell server managing
@@ -723,9 +723,19 @@ cloudos datasets ls <path> \
723
723
  --workspace-id $WORKSPACE_ID \
724
724
  --project-name $PROJEC_NAME
725
725
  ```
726
+
727
+
726
728
  The output of this command is a list of files and folders present in the specified project.
727
729
  If the `<path>` is left empty, the command will return the list of folders present in the selected project.
728
730
 
731
+ If you require more information on the files and folder listed, you can use the `--details` flag that will output a table containing the following columns:
732
+ - Type (folder or file)
733
+ - Owner
734
+ - Size in human readable format
735
+ - Last updated
736
+ - Filepath (the file or folder name)
737
+ - S3 Path
738
+
729
739
  ### WDL pipeline support
730
740
 
731
741
  #### Cromwell server managing
@@ -8,11 +8,14 @@ from cloudos_cli.queue.queue import Queue
8
8
  import json
9
9
  import time
10
10
  import sys
11
- import os
12
- import urllib3
13
11
  from ._version import __version__
14
12
  from cloudos_cli.configure.configure import ConfigurationProfile
15
13
  from cloudos_cli.datasets import Datasets
14
+ from cloudos_cli.utils.resources import ssl_selector, format_bytes
15
+ from rich.console import Console
16
+ from rich.table import Table
17
+ from rich.style import Style
18
+
16
19
 
17
20
  # GLOBAL VARS
18
21
  JOB_COMPLETED = 'completed'
@@ -27,39 +30,6 @@ ABORT_JOB_STATES = ['running', 'initializing']
27
30
  CLOUDOS_URL = 'https://cloudos.lifebit.ai'
28
31
  INIT_PROFILE = 'initialisingProfile'
29
32
 
30
-
31
- def ssl_selector(disable_ssl_verification, ssl_cert):
32
- """Verify value selector.
33
-
34
- This function stablish the value that will be passed to requests.verify
35
- variable.
36
-
37
- Parameters
38
- ----------
39
- disable_ssl_verification : bool
40
- Whether to disable SSL verification.
41
- ssl_cert : string
42
- String indicating the path to the SSL certificate file to use.
43
-
44
- Returns
45
- -------
46
- verify_ssl : [bool | string]
47
- Either a bool or a path string to be passed to requests.verify to control
48
- SSL verification.
49
- """
50
- if disable_ssl_verification:
51
- verify_ssl = False
52
- print('[WARNING] Disabling SSL verification')
53
- urllib3.disable_warnings()
54
- elif ssl_cert is None:
55
- verify_ssl = True
56
- elif os.path.isfile(ssl_cert):
57
- verify_ssl = ssl_cert
58
- else:
59
- raise FileNotFoundError(f"The specified file '{ssl_cert}' was not found")
60
- return verify_ssl
61
-
62
-
63
33
  @click.group()
64
34
  @click.version_option(__version__)
65
35
  @click.pass_context
@@ -1855,6 +1825,11 @@ def run_bash_job(ctx,
1855
1825
  @click.option('--project-name',
1856
1826
  help='The name of a CloudOS project.')
1857
1827
  @click.option('--profile', help='Profile to use from the config file', default=None)
1828
+ @click.option('--details',
1829
+ help=('When selected, it prints the details of the listed files. ' +
1830
+ 'Details contains "Type", "Owner", "Size", "Last Updated", ' +
1831
+ '"Filepath", "S3 Path".'),
1832
+ is_flag=True)
1858
1833
  @click.pass_context
1859
1834
  def list_files(ctx,
1860
1835
  apikey,
@@ -1864,14 +1839,14 @@ def list_files(ctx,
1864
1839
  ssl_cert,
1865
1840
  project_name,
1866
1841
  profile,
1867
- path):
1842
+ path,
1843
+ details):
1868
1844
  """List contents of a path within a CloudOS workspace dataset."""
1869
1845
 
1870
1846
  # fallback to ctx default if profile not specified
1871
1847
  profile = profile or ctx.default_map['datasets']['list'].get('profile')
1872
1848
 
1873
1849
  config_manager = ConfigurationProfile()
1874
-
1875
1850
  required_dict = {
1876
1851
  'apikey': True,
1877
1852
  'workspace_id': True,
@@ -1879,7 +1854,6 @@ def list_files(ctx,
1879
1854
  'project_name': False
1880
1855
  }
1881
1856
 
1882
- # Unpack profile values first
1883
1857
  apikey, cloudos_url, workspace_id, workflow_name, repository_platform, execution_platform, project_name = (
1884
1858
  config_manager.load_profile_and_validate_data(
1885
1859
  ctx,
@@ -1912,21 +1886,69 @@ def list_files(ctx,
1912
1886
  result = datasets.list_folder_content(path)
1913
1887
  contents = result.get("contents") or result.get("datasets", [])
1914
1888
  if not contents:
1915
- files = result.get("files", [])
1916
- folders = result.get("folders", [])
1917
- contents = [{"name": f["name"], "isDir": False} for f in files] + \
1918
- [{"name": f["name"], "isDir": True} for f in folders]
1889
+ contents = result.get("files", []) + result.get("folders", [])
1890
+
1891
+ if details:
1892
+ console = Console(width=None) # Avoid terminal width truncation
1893
+
1894
+ table = Table(show_header=True, header_style="bold white")
1895
+ table.add_column("Type", style="cyan", no_wrap=True)
1896
+ table.add_column("Owner", style="white")
1897
+ table.add_column("Size", style="magenta")
1898
+ table.add_column("Last Updated", style="green")
1899
+ table.add_column("Filepath", style="bold", overflow="fold")
1900
+ table.add_column("S3 Path", style="dim", no_wrap=False, overflow="fold", ratio=2)
1901
+
1902
+ for item in contents:
1903
+ is_folder = "folderType" in item or item.get("isDir", False)
1904
+ type_ = "folder" if is_folder else "file"
1905
+
1906
+ user = item.get("user")
1907
+ if isinstance(user, dict):
1908
+ name = user.get("name", "").strip()
1909
+ surname = user.get("surname", "").strip()
1910
+ if name and surname:
1911
+ owner = f"{name} {surname}"
1912
+ elif name:
1913
+ owner = name
1914
+ elif surname:
1915
+ owner = surname
1916
+ else:
1917
+ owner = "-"
1918
+ else:
1919
+ owner = "-"
1920
+
1921
+ raw_size = item.get("sizeInBytes", item.get("size"))
1922
+ size = format_bytes(raw_size) if not is_folder and raw_size is not None else "-"
1923
+
1924
+ updated = item.get("updatedAt") or item.get("lastModified", "-")
1925
+ filepath = item.get("name", "-")
1926
+
1927
+ if is_folder:
1928
+ s3_bucket = item.get("s3BucketName")
1929
+ s3_key = item.get("s3Prefix")
1930
+ s3_path = f"s3://{s3_bucket}/{s3_key}" if s3_bucket and s3_key else "-"
1931
+ else:
1932
+ s3_bucket = item.get("s3BucketName")
1933
+ s3_key = item.get("s3ObjectKey") or item.get("s3Prefix")
1934
+ s3_path = f"s3://{s3_bucket}/{s3_key}" if s3_bucket and s3_key else "-"
1935
+
1936
+ style = Style(color="blue", underline=True) if is_folder else None
1937
+ table.add_row(type_, owner, size, updated, filepath, s3_path, style=style)
1938
+
1939
+ console.print(table)
1919
1940
 
1920
- for item in contents:
1921
- name = item.get("name", "")
1922
- if item.get("isDir"):
1923
- name = click.style(name, fg="blue", underline=True)
1924
- click.echo(name)
1941
+ else:
1942
+ console = Console()
1943
+ for item in contents:
1944
+ name = item.get("name", "")
1945
+ if item.get("isDir"):
1946
+ console.print(f"[blue underline]{name}[/]")
1947
+ else:
1948
+ console.print(name)
1925
1949
 
1926
1950
  except Exception as e:
1927
1951
  click.echo(f"[ERROR] {str(e)}", err=True)
1928
1952
 
1929
-
1930
1953
  if __name__ == "__main__":
1931
1954
  run_cloudos_cli()
1932
-
@@ -0,0 +1 @@
1
+ __version__ = '2.27.0'
@@ -150,7 +150,12 @@ class Datasets(Cloudos):
150
150
  self.project_id,
151
151
  self.workspace_id),
152
152
  headers=headers, verify=self.verify)
153
- return r.json()
153
+ raw = r.json()
154
+
155
+ # Normalize response
156
+ for item in raw.get("datasets", []):
157
+ item["folderType"] = True
158
+ return raw
154
159
 
155
160
  def list_datasets_content(self, folder_name):
156
161
  """Uses
@@ -187,6 +192,7 @@ class Datasets(Cloudos):
187
192
  self.workspace_id),
188
193
  headers=headers, verify=self.verify)
189
194
  return r.json()
195
+
190
196
  def list_s3_folder_content(self, s3_bucket_name, s3_relative_path):
191
197
  """Uses
192
198
  ----------
@@ -4,6 +4,6 @@ Utility functions and classes to use across the package.
4
4
 
5
5
  from .errors import BadRequestException, TimeOutException
6
6
  from .requests import retry_requests_get, retry_requests_post
7
+ from .resources import format_bytes, ssl_selector
7
8
 
8
-
9
- __all__ = ['errors', 'requests']
9
+ __all__ = ['errors', 'requests', 'resources']
@@ -0,0 +1,46 @@
1
+ import os
2
+ import urllib3
3
+
4
+ def format_bytes(size):
5
+ """Convert bytes to human-readable format (e.g., 1.2 MB)."""
6
+ if size is None:
7
+ return "-"
8
+ power = 1024
9
+ n = 0
10
+ labels = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']
11
+ while size >= power and n < len(labels) - 1:
12
+ size /= power
13
+ n += 1
14
+ return f"{size:.1f} {labels[n]}"
15
+
16
+
17
+ def ssl_selector(disable_ssl_verification, ssl_cert):
18
+ """Verify value selector.
19
+
20
+ This function stablish the value that will be passed to requests.verify
21
+ variable.
22
+
23
+ Parameters
24
+ ----------
25
+ disable_ssl_verification : bool
26
+ Whether to disable SSL verification.
27
+ ssl_cert : string
28
+ String indicating the path to the SSL certificate file to use.
29
+
30
+ Returns
31
+ -------
32
+ verify_ssl : [bool | string]
33
+ Either a bool or a path string to be passed to requests.verify to control
34
+ SSL verification.
35
+ """
36
+ if disable_ssl_verification:
37
+ verify_ssl = False
38
+ print('[WARNING] Disabling SSL verification')
39
+ urllib3.disable_warnings()
40
+ elif ssl_cert is None:
41
+ verify_ssl = True
42
+ elif os.path.isfile(ssl_cert):
43
+ verify_ssl = ssl_cert
44
+ else:
45
+ raise FileNotFoundError(f"The specified file '{ssl_cert}' was not found")
46
+ return verify_ssl
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloudos_cli
3
- Version: 2.26.1
3
+ Version: 2.27.0
4
4
  Summary: Python package for interacting with CloudOS
5
5
  Home-page: https://github.com/lifebit-ai/cloudos-cli
6
6
  Author: David Piñeyro
@@ -758,9 +758,19 @@ cloudos datasets ls <path> \
758
758
  --workspace-id $WORKSPACE_ID \
759
759
  --project-name $PROJEC_NAME
760
760
  ```
761
+
762
+
761
763
  The output of this command is a list of files and folders present in the specified project.
762
764
  If the `<path>` is left empty, the command will return the list of folders present in the selected project.
763
765
 
766
+ If you require more information on the files and folder listed, you can use the `--details` flag that will output a table containing the following columns:
767
+ - Type (folder or file)
768
+ - Owner
769
+ - Size in human readable format
770
+ - Last updated
771
+ - Filepath (the file or folder name)
772
+ - S3 Path
773
+
764
774
  ### WDL pipeline support
765
775
 
766
776
  #### Cromwell server managing
@@ -24,5 +24,6 @@ cloudos_cli/queue/queue.py
24
24
  cloudos_cli/utils/__init__.py
25
25
  cloudos_cli/utils/errors.py
26
26
  cloudos_cli/utils/requests.py
27
+ cloudos_cli/utils/resources.py
27
28
  tests/__init__.py
28
29
  tests/functions_for_pytest.py
@@ -1 +0,0 @@
1
- __version__ = '2.26.1'
File without changes
File without changes
File without changes