divbase-cli 0.1.1__tar.gz → 0.1.3__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 (29) hide show
  1. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/PKG-INFO +2 -2
  2. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/pyproject.toml +1 -1
  3. divbase_cli-0.1.3/src/divbase_cli/__init__.py +1 -0
  4. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_commands/auth_cli.py +10 -1
  5. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_commands/dimensions_cli.py +1 -1
  6. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_commands/file_cli.py +5 -3
  7. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/services/s3_files.py +5 -2
  8. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/user_config.py +2 -4
  9. divbase_cli-0.1.1/src/divbase_cli/__init__.py +0 -1
  10. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/.gitignore +0 -0
  11. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/README.md +0 -0
  12. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_commands/__init__.py +0 -0
  13. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_commands/query_cli.py +0 -0
  14. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_commands/shared_args_options.py +0 -0
  15. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_commands/task_history_cli.py +0 -0
  16. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_commands/user_config_cli.py +0 -0
  17. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_commands/version_cli.py +0 -0
  18. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_config.py +0 -0
  19. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/cli_exceptions.py +0 -0
  20. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/config_resolver.py +0 -0
  21. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/display_task_history.py +0 -0
  22. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/divbase_cli.py +0 -0
  23. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/retries.py +0 -0
  24. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/services/__init__.py +0 -0
  25. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/services/announcements.py +0 -0
  26. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/services/pre_signed_urls.py +0 -0
  27. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/services/project_versions.py +0 -0
  28. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/user_auth.py +0 -0
  29. {divbase_cli-0.1.1 → divbase_cli-0.1.3}/src/divbase_cli/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: divbase-cli
3
- Version: 0.1.1
3
+ Version: 0.1.3
4
4
  Summary: Command Line Interface for Divbase
5
5
  Project-URL: Homepage, https://divbase.scilifelab-2-prod.sys.kth.se
6
6
  Project-URL: Documentation, https://scilifelabdatacentre.github.io/divbase
@@ -18,7 +18,7 @@ Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
19
  Classifier: Programming Language :: Python :: 3.14
20
20
  Requires-Python: >=3.12
21
- Requires-Dist: divbase-lib==0.1.1
21
+ Requires-Dist: divbase-lib==0.1.3
22
22
  Requires-Dist: keyring==25.7.0
23
23
  Requires-Dist: typer==0.27.2
24
24
  Description-Content-Type: text/markdown
@@ -10,7 +10,7 @@ requires-python = ">=3.12"
10
10
  dependencies = [
11
11
  "typer==0.27.2",
12
12
  "keyring==25.7.0",
13
- "divbase-lib==0.1.1",
13
+ "divbase-lib==0.1.3",
14
14
  ]
15
15
  dynamic = ["version"]
16
16
 
@@ -0,0 +1 @@
1
+ __version__ = "0.1.3"
@@ -183,6 +183,15 @@ def whoami():
183
183
  divbase_base_url=divbase_url,
184
184
  api_route="v1/auth/whoami",
185
185
  )
186
-
186
+ # non-authenticated request will have raised by now, so either login session or valid PAT.
187
187
  current_user = request.json()
188
188
  print(f"Currently logged in as: {current_user['email']} (Name: {current_user['name']})")
189
+
190
+ config = load_user_config()
191
+ login_session_expires_at = check_existing_session(divbase_url=divbase_url, config=config)
192
+ if login_session_expires_at:
193
+ print(f"Login session will expire at: {format_unix_timestamp_for_cli(unix_timestamp=login_session_expires_at)}")
194
+ else:
195
+ # PAT can come from env var or os keyring, if env var we can't know expiry time and env var takes priority over keyring.
196
+ # so best to not show expiry time here as could be wrong if both are set.
197
+ print("Authenticated via personal access token (PAT).")
@@ -305,7 +305,7 @@ def create_metadata_template_with_project_samples_names(
305
305
  return
306
306
 
307
307
  with open(output_path, mode="w", newline="") as tsvfile:
308
- writer = csv.writer(tsvfile, delimiter="\t")
308
+ writer = csv.writer(tsvfile, delimiter="\t", lineterminator="\n")
309
309
  writer.writerow(["#Sample_ID"])
310
310
  for sample in unique_sample_names_sorted:
311
311
  writer.writerow([sample])
@@ -2,6 +2,7 @@
2
2
  Command line interface for managing files in a DivBase project's store on DivBase.
3
3
  """
4
4
 
5
+ import sys
5
6
  from collections import defaultdict
6
7
  from glob import glob
7
8
  from pathlib import Path
@@ -904,12 +905,13 @@ def _print_ls_simple(files: list[ObjectDetails], folders: list[str]) -> None:
904
905
 
905
906
 
906
907
  def _print_ls_tsv_format(files: list[ObjectDetails], folders: list[str]) -> None:
907
- """Prints the files and folders in a tab-separated format - for programmatic use"""
908
+ """Prints the files and folders in a tab-separated format - for programmatic use."""
908
909
  for folder in folders:
909
- print(f"{markup_escape(folder)}\t-\t-")
910
+ # using sys.stdout instead of rich's print, as rich converts tabs into spaces.
911
+ sys.stdout.write(f"{folder}\t-\t-\n")
910
912
  for f in files:
911
913
  last_modified = format_datetime_for_cli(dt=f.last_modified)
912
- print(f"{markup_escape(f.name)}\t{format_file_size(f.size)}\t{last_modified}")
914
+ sys.stdout.write(f"{f.name}\t{format_file_size(f.size)}\t{last_modified}\n")
913
915
 
914
916
 
915
917
  def _print_ls_detailed(files: list[ObjectDetails], folders: list[str]) -> None:
@@ -2,6 +2,7 @@
2
2
  Service layer for DivBase CLI S3 file operations.
3
3
  """
4
4
 
5
+ import os
5
6
  import sys
6
7
  from dataclasses import dataclass
7
8
  from pathlib import Path
@@ -331,9 +332,11 @@ def stream_file_command(
331
332
  for chunk in response.iter_bytes():
332
333
  sys.stdout.buffer.write(chunk)
333
334
  except BrokenPipeError:
334
- # This happens when the user pipes to a command that closes early
335
+ # This happens when the user pipes to a command that closes early which is okay
335
336
  # (e.g., `[divbase-cli stream command] | head -n 10`).
336
- pass
337
+ # See: https://docs.python.org/3/library/signal.html#note-on-sigpipe
338
+ devnull = os.open(os.devnull, os.O_WRONLY)
339
+ os.dup2(devnull, sys.stdout.fileno())
337
340
 
338
341
 
339
342
  def upload_files_command(
@@ -8,7 +8,6 @@ under the user application data directory on Linux, macOS, or Windows).
8
8
  """
9
9
 
10
10
  import logging
11
- import warnings
12
11
  from dataclasses import dataclass, field
13
12
  from pathlib import Path
14
13
 
@@ -69,9 +68,8 @@ class UserConfig:
69
68
  new_project = ProjectConfig(name=name, divbase_url=divbase_url)
70
69
 
71
70
  if new_project.name in self.all_project_names:
72
- warnings.warn(
73
- f"""The project: '{new_project.name}' already existed in your configuration file. It will be replaced with your new params""",
74
- stacklevel=2,
71
+ print(
72
+ f"The project: '{new_project.name}' already existed in your configuration file. It will be replaced with your new params."
75
73
  )
76
74
 
77
75
  self.projects = [project for project in self.projects if project.name != new_project.name]
@@ -1 +0,0 @@
1
- __version__ = "0.1.1"
File without changes
File without changes