divbase-cli 0.1.0.dev5__tar.gz → 0.1.2__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 (34) hide show
  1. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/.gitignore +21 -2
  2. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/PKG-INFO +6 -5
  3. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/pyproject.toml +5 -5
  4. divbase_cli-0.1.2/src/divbase_cli/__init__.py +1 -0
  5. divbase_cli-0.1.2/src/divbase_cli/cli_commands/auth_cli.py +188 -0
  6. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/cli_commands/dimensions_cli.py +58 -35
  7. divbase_cli-0.1.2/src/divbase_cli/cli_commands/file_cli.py +1192 -0
  8. divbase_cli-0.1.2/src/divbase_cli/cli_commands/query_cli.py +413 -0
  9. divbase_cli-0.1.2/src/divbase_cli/cli_commands/shared_args_options.py +33 -0
  10. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/cli_commands/task_history_cli.py +33 -42
  11. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/cli_commands/user_config_cli.py +37 -21
  12. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/cli_commands/version_cli.py +36 -48
  13. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/cli_config.py +29 -6
  14. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/cli_exceptions.py +89 -46
  15. divbase_cli-0.1.2/src/divbase_cli/config_resolver.py +87 -0
  16. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/display_task_history.py +48 -45
  17. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/divbase_cli.py +29 -11
  18. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/retries.py +11 -1
  19. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/services/announcements.py +2 -2
  20. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/services/pre_signed_urls.py +85 -41
  21. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/services/s3_files.py +195 -81
  22. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/user_auth.py +254 -51
  23. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/user_config.py +3 -5
  24. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/utils.py +14 -2
  25. divbase_cli-0.1.0.dev5/src/divbase_cli/__init__.py +0 -1
  26. divbase_cli-0.1.0.dev5/src/divbase_cli/cli_commands/auth_cli.py +0 -98
  27. divbase_cli-0.1.0.dev5/src/divbase_cli/cli_commands/file_cli.py +0 -632
  28. divbase_cli-0.1.0.dev5/src/divbase_cli/cli_commands/query_cli.py +0 -149
  29. divbase_cli-0.1.0.dev5/src/divbase_cli/cli_commands/shared_args_options.py +0 -23
  30. divbase_cli-0.1.0.dev5/src/divbase_cli/config_resolver.py +0 -84
  31. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/README.md +0 -0
  32. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/cli_commands/__init__.py +0 -0
  33. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/services/__init__.py +0 -0
  34. {divbase_cli-0.1.0.dev5 → divbase_cli-0.1.2}/src/divbase_cli/services/project_versions.py +0 -0
@@ -22,6 +22,9 @@ __pycache__/
22
22
  tests/fixtures/temp*
23
23
  tests/fixtures/merged*
24
24
  divbase_metadata_template*.tsv
25
+ # query results files
26
+ result_of_job_*.vcf.gz
27
+ result_of_job_*.log
25
28
 
26
29
  # query job config files
27
30
  bcftools_divbase_job_config.json
@@ -34,13 +37,29 @@ split_scaffold_files.txt
34
37
  scripts/benchmarking/*.yaml
35
38
  scripts/benchmarking/results
36
39
 
40
+ # pytest-cov generate files
41
+ .coverage
42
+ .coverage.*
43
+ htmlcov/
44
+ docker/coverage-data/
45
+
46
+ # log files written by docker compose, if env var set to do so (by default no)
47
+ docker/logs/*
48
+ !docker/logs/.gitkeep
49
+
37
50
  #MacOS artifacts
38
51
  .DS_Store
39
52
 
40
- # mkdocs build cache
53
+ # mkdocs/zensical build cache
41
54
  .cache/
42
- # mkdocs auto generated files
55
+ site/
56
+ # documentation site's auto generated files
43
57
  docs/cli/_auto_generated/*.md
58
+ docs/releases/index.md
59
+ docs/llms.txt
60
+ docs/llms-full.txt
61
+ docs/llms-users.txt
62
+
44
63
 
45
64
  # pypi
46
65
  dist/
@@ -1,8 +1,8 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: divbase-cli
3
- Version: 0.1.0.dev5
3
+ Version: 0.1.2
4
4
  Summary: Command Line Interface for Divbase
5
- Project-URL: Homepage, https://divbase.scilifelab.se
5
+ Project-URL: Homepage, https://divbase.scilifelab-2-prod.sys.kth.se
6
6
  Project-URL: Documentation, https://scilifelabdatacentre.github.io/divbase
7
7
  Project-URL: Repository, https://github.com/ScilifelabDataCentre/divbase
8
8
  Project-URL: Issues, https://github.com/ScilifelabDataCentre/divbase/issues
@@ -18,8 +18,9 @@ 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.0.dev5
22
- Requires-Dist: typer==0.24.1
21
+ Requires-Dist: divbase-lib==0.1.2
22
+ Requires-Dist: keyring==25.7.0
23
+ Requires-Dist: typer==0.27.2
23
24
  Description-Content-Type: text/markdown
24
25
 
25
26
  # divbase-cli
@@ -8,8 +8,9 @@ authors = [
8
8
  ]
9
9
  requires-python = ">=3.12"
10
10
  dependencies = [
11
- "typer==0.24.1",
12
- "divbase-lib==0.1.0.dev5"
11
+ "typer==0.27.2",
12
+ "keyring==25.7.0",
13
+ "divbase-lib==0.1.2",
13
14
  ]
14
15
  dynamic = ["version"]
15
16
 
@@ -26,14 +27,13 @@ classifiers = [
26
27
  ]
27
28
 
28
29
  [project.urls]
29
- Homepage = "https://divbase.scilifelab.se"
30
+ Homepage = "https://divbase.scilifelab-2-prod.sys.kth.se"
30
31
  Documentation = "https://scilifelabdatacentre.github.io/divbase"
31
32
  Repository = "https://github.com/ScilifelabDataCentre/divbase"
32
33
  Issues = "https://github.com/ScilifelabDataCentre/divbase/issues"
33
34
 
34
35
  [project.scripts]
35
- divbase = "divbase_cli.divbase_cli:main"
36
- divbase-cli = "divbase_cli.divbase_cli:main" # TODO choose 1
36
+ divbase-cli = "divbase_cli.divbase_cli:main"
37
37
 
38
38
  [build-system]
39
39
  requires = ["hatchling >= 1.26"]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.2"
@@ -0,0 +1,188 @@
1
+ """
2
+ CLI subcommand for managing user auth with DivBase server.
3
+ """
4
+
5
+ import logging
6
+ import time
7
+
8
+ import typer
9
+ from pydantic import SecretStr
10
+ from rich import print
11
+
12
+ from divbase_cli.cli_config import cli_settings
13
+ from divbase_cli.cli_exceptions import (
14
+ DivBaseAPIConnectionError,
15
+ DivBaseAPIError,
16
+ InvalidPersonalAccessTokenError,
17
+ PersonalAccessTokenAlreadyExistsError,
18
+ )
19
+ from divbase_cli.config_resolver import resolve_url_for_non_project_specific_commands
20
+ from divbase_cli.services.announcements import get_and_display_announcements
21
+ from divbase_cli.user_auth import (
22
+ PERSONAL_ACCESS_TOKEN_EXPIRED_MESSAGE,
23
+ PATData,
24
+ check_existing_session,
25
+ delete_stored_pat,
26
+ load_stored_user_pat,
27
+ login_to_divbase,
28
+ logout_of_divbase,
29
+ make_authenticated_request,
30
+ )
31
+ from divbase_cli.user_config import load_user_config
32
+ from divbase_lib.divbase_constants import PAT_TOKEN_PREFIX
33
+ from divbase_lib.utils import format_unix_timestamp_for_cli
34
+
35
+ logger = logging.getLogger(__name__)
36
+
37
+ divbase_home_url = cli_settings.DIVBASE_API_URL.replace("/api", "")
38
+
39
+ auth_app = typer.Typer(
40
+ no_args_is_help=True,
41
+ help=f"Log in/out of DivBase and manage your personal access tokens. To register, visit {divbase_home_url}.",
42
+ )
43
+
44
+
45
+ @auth_app.command("login")
46
+ def login(
47
+ email: str,
48
+ divbase_url: str = typer.Option(cli_settings.DIVBASE_API_URL, help="DivBase server URL to connect to."),
49
+ force: bool = typer.Option(False, "--force", "-f", help="Log in again even if already logged in."),
50
+ ):
51
+ """
52
+ Log in to DivBase.
53
+
54
+ You'll be prompted for your password after running the command.
55
+ """
56
+ password: str = typer.prompt("please enter your password", hide_input=True, confirmation_prompt=False)
57
+ secret_password = SecretStr(password)
58
+ del password # avoid user passwords showing up in error messages etc...
59
+
60
+ config = load_user_config()
61
+
62
+ if not force:
63
+ session_expires_at = check_existing_session(divbase_url=divbase_url, config=config)
64
+ if session_expires_at:
65
+ print(f"Already logged in to {divbase_url} with email: {config.logged_in_email}.")
66
+ print(f"Session expires: {format_unix_timestamp_for_cli(unix_timestamp=session_expires_at)}")
67
+
68
+ if not typer.confirm("Do you want to login again? This will replace your current session."):
69
+ print("Login cancelled.")
70
+ return
71
+
72
+ login_to_divbase(email=email, password=secret_password, divbase_url=divbase_url)
73
+
74
+ try:
75
+ get_and_display_announcements(divbase_base_url=divbase_url)
76
+ except (DivBaseAPIError, DivBaseAPIConnectionError):
77
+ # lets not fail the login process if announcements are not working.
78
+ logger.info("Failed to get announcements after login. Error was: ", exc_info=True)
79
+
80
+ print(f"Logged in successfully as: {email}")
81
+
82
+
83
+ @auth_app.command("logout")
84
+ def logout():
85
+ """
86
+ Log out of DivBase.
87
+
88
+ Removes your locally stored credentials and invalidates the server-side refresh token.
89
+ """
90
+ logout_of_divbase()
91
+ print("Logged out successfully.")
92
+
93
+
94
+ @auth_app.command("add-pat")
95
+ def add_pat(
96
+ name: str = typer.Argument(..., help="Name of the personal access token (PAT), e.g. 'work-laptop-pat'."),
97
+ expires_unix_timestamp: int | None = typer.Option(
98
+ None,
99
+ "--expires",
100
+ "-e",
101
+ help="When the personal access token (PAT) expires (if it does), as a Unix timestamp.",
102
+ min=1,
103
+ ),
104
+ overwrite_existing: bool = typer.Option(
105
+ False, "--overwrite-existing", "-o", help="Overwrite the existing stored PAT if one already exists."
106
+ ),
107
+ ):
108
+ """
109
+ Add a personal access token (PAT) to your device for authentication with DivBase.
110
+
111
+ PATs are used for authenticating with DivBase instead of using your password, and are recommended for use in scripts and pipelines.
112
+ See https://scilifelabdatacentre.github.io/divbase/user-guides/using-divbase-programmatically/ for more details on how to create a personal access token.
113
+ You can only store one personal access token at a time.
114
+ """
115
+ existing = load_stored_user_pat()
116
+ if existing and not overwrite_existing:
117
+ raise PersonalAccessTokenAlreadyExistsError(
118
+ f"A personal access token named '{existing.name}' is already stored on your device \n"
119
+ f"It is due to expire on: {existing.pat_expiry_formatted()} \n"
120
+ "Append the flag --overwrite-existing (-o) to this command if you want to replace it. \n"
121
+ "You can only store one PAT at a time."
122
+ )
123
+
124
+ if expires_unix_timestamp and expires_unix_timestamp < time.time():
125
+ raise InvalidPersonalAccessTokenError(
126
+ "The expiry time you entered is in the past. Please enter a valid expiry time for the PAT."
127
+ )
128
+
129
+ pat = SecretStr(
130
+ typer.prompt("please paste your personal access token now", hide_input=True, confirmation_prompt=False)
131
+ )
132
+ if not pat.get_secret_value().startswith(PAT_TOKEN_PREFIX):
133
+ raise InvalidPersonalAccessTokenError(
134
+ "It looks like the token you entered is not a valid personal access token. "
135
+ f"Please make sure you copied the entire token, including the '{PAT_TOKEN_PREFIX}' prefix."
136
+ )
137
+
138
+ pat_data = PATData(name=name, pat=pat, pat_expires_at=expires_unix_timestamp)
139
+ pat_data.dump_pat_data()
140
+ print(f"Personal access token '{name}' stored successfully.")
141
+
142
+
143
+ @auth_app.command("rm-pat")
144
+ def rm_pat():
145
+ """
146
+ Remove the stored personal access token from your device.
147
+
148
+ If no such token exists the command will still succeed.
149
+ """
150
+ delete_stored_pat()
151
+ print("If a personal access token was stored, it has now been removed.")
152
+
153
+
154
+ @auth_app.command("pat-info")
155
+ def pat_info():
156
+ """
157
+ Display information about the personal access token stored on this device, if any.
158
+
159
+ The token will not be displayed for security reasons, but the name and expiry time will be shown.
160
+ """
161
+ pat_data = load_stored_user_pat()
162
+ if not pat_data:
163
+ print("No personal access token stored on this device.")
164
+ return
165
+
166
+ print(f"Name: {pat_data.name}")
167
+ print(f"Expires: {pat_data.pat_expiry_formatted()}")
168
+
169
+ if pat_data.is_pat_expired():
170
+ print("[red bold]Warning [/red bold]")
171
+ print(PERSONAL_ACCESS_TOKEN_EXPIRED_MESSAGE)
172
+
173
+
174
+ @auth_app.command("whoami")
175
+ def whoami():
176
+ """
177
+ Show information about the account you are currently logged in with.
178
+ """
179
+ divbase_url = resolve_url_for_non_project_specific_commands()
180
+
181
+ request = make_authenticated_request(
182
+ method="GET",
183
+ divbase_base_url=divbase_url,
184
+ api_route="v1/auth/whoami",
185
+ )
186
+
187
+ current_user = request.json()
188
+ print(f"Currently logged in as: {current_user['email']} (Name: {current_user['name']})")
@@ -1,27 +1,32 @@
1
1
  import csv
2
2
  import logging
3
+ from datetime import datetime
3
4
  from pathlib import Path
4
5
 
5
6
  import typer
6
7
  import yaml
7
8
  from rich import print
9
+ from rich.table import Table
8
10
 
9
11
  from divbase_cli.cli_commands.shared_args_options import PROJECT_NAME_OPTION
10
- from divbase_cli.config_resolver import resolve_project
12
+ from divbase_cli.config_resolver import resolve_and_authenticate_project
11
13
  from divbase_cli.user_auth import make_authenticated_request
14
+ from divbase_cli.utils import print_rich_table_as_tsv
12
15
  from divbase_lib.api_schemas.vcf_dimensions import (
13
16
  DimensionsSamplesResult,
14
17
  DimensionsScaffoldsResult,
15
18
  DimensionsShowResult,
19
+ DimensionsVCFFilesResult,
16
20
  )
17
21
  from divbase_lib.metadata_validator import SharedMetadataValidator
22
+ from divbase_lib.utils import format_datetime_for_cli
18
23
 
19
24
  logger = logging.getLogger(__name__)
20
25
 
21
26
 
22
27
  dimensions_app = typer.Typer(
23
28
  no_args_is_help=True,
24
- help="Create and inspect dimensions (number of samples, number of variants, scaffold names) of the VCF files in a project",
29
+ help="Create and inspect dimensions (number of samples, number of variants, scaffold names) of the VCF files in a project, and create/validate sample metadata files.",
25
30
  )
26
31
 
27
32
 
@@ -29,10 +34,8 @@ dimensions_app = typer.Typer(
29
34
  def update_dimensions_index(
30
35
  project: str | None = PROJECT_NAME_OPTION,
31
36
  ) -> None:
32
- """Calculate and add the dimensions of a VCF file to the dimensions index file in the project."""
33
-
34
- project_config = resolve_project(project_name=project)
35
-
37
+ """Calculate and add the dimensions of all VCF files in the project to the dimensions cache in the project."""
38
+ project_config = resolve_and_authenticate_project(project_name=project)
36
39
  response = make_authenticated_request(
37
40
  method="PUT",
38
41
  divbase_base_url=project_config.divbase_url,
@@ -40,7 +43,9 @@ def update_dimensions_index(
40
43
  )
41
44
 
42
45
  task_id = response.json()
43
- print(f"Job submitted successfully with task id: {task_id}")
46
+ print(
47
+ f"Job submitted successfully with task id: {task_id}. To check the status of your job, use the command: divbase-cli task-history id {task_id}"
48
+ )
44
49
 
45
50
 
46
51
  @dimensions_app.command("show")
@@ -54,14 +59,21 @@ def show_dimensions_index(
54
59
  typer.Option(
55
60
  False,
56
61
  "--unique-scaffolds",
57
- help="If set, will show all unique scaffold names found across all the VCF files in the project.",
62
+ help="If set, will show all unique scaffold names found across all the VCF files in the project's VCF dimensions cache.",
58
63
  )
59
64
  ),
60
65
  unique_samples: bool = (
61
66
  typer.Option(
62
67
  False,
63
68
  "--unique-samples",
64
- help="If set, will show all unique sample names found across all the VCF files in the project.",
69
+ help="If set, will show all unique sample names found across all the VCF files in the project's VCF dimensions cache.",
70
+ )
71
+ ),
72
+ unique_vcf_files: bool = (
73
+ typer.Option(
74
+ False,
75
+ "--cached-vcf-files",
76
+ help="If set, will show all VCF file entries (filename and version ID) found in the project's VCF dimensions cache.",
65
77
  )
66
78
  ),
67
79
  sample_names_limit: int = typer.Option(
@@ -84,18 +96,13 @@ def show_dimensions_index(
84
96
  project: str | None = PROJECT_NAME_OPTION,
85
97
  ) -> None:
86
98
  """
87
- Show the dimensions index file for a project.
99
+ Show the dimensions cache file for a project.
88
100
  When running --unique-scaffolds, the sorting separates between numeric and non-numeric scaffold names.
89
101
  """
90
-
91
- project_config = resolve_project(project_name=project)
92
-
93
- # These two options are mutually exclusive. But due to how typer handles options, this error will only be raised if --sample-names-output has an input value (i.e. path).
94
- # If the path is missing, it will raise an error about the missing path argument instead...
95
102
  if sample_names_output and sample_names_stdout:
96
- typer.echo("Use only one of --sample-names-output or --sample-names-stdout.", err=True)
97
- raise typer.Exit(code=1)
103
+ raise typer.BadParameter("Use only one of --sample-names-output or --sample-names-stdout.")
98
104
 
105
+ project_config = resolve_and_authenticate_project(project_name=project)
99
106
  if unique_samples:
100
107
  response = make_authenticated_request(
101
108
  method="GET",
@@ -141,6 +148,28 @@ def show_dimensions_index(
141
148
  )
142
149
  return
143
150
 
151
+ if unique_vcf_files:
152
+ response = make_authenticated_request(
153
+ method="GET",
154
+ divbase_base_url=project_config.divbase_url,
155
+ api_route=f"v1/vcf-dimensions/projects/{project_config.name}/vcf-files",
156
+ )
157
+ unique_vcf_files_with_versions = DimensionsVCFFilesResult(**response.json()).unique_vcf_files
158
+ unique_vcf_files_with_versions = sorted(
159
+ unique_vcf_files_with_versions,
160
+ key=lambda entry: entry.vcf_file_s3_key,
161
+ )
162
+
163
+ table = Table()
164
+ table.add_column("Filename")
165
+ table.add_column("S3 version ID")
166
+
167
+ for entry in unique_vcf_files_with_versions:
168
+ table.add_row(entry.vcf_file_s3_key, entry.s3_version_id)
169
+
170
+ print_rich_table_as_tsv(table=table)
171
+ return
172
+
144
173
  response = make_authenticated_request(
145
174
  method="GET",
146
175
  divbase_base_url=project_config.divbase_url,
@@ -205,7 +234,7 @@ def _format_api_response_for_display_in_terminal(api_response: DimensionsShowRes
205
234
  dimensions_entry = {
206
235
  "filename": entry["vcf_file_s3_key"],
207
236
  "file_version_ID_in_bucket": entry["s3_version_id"],
208
- "last_updated": entry.get("updated_at"),
237
+ "last_updated": format_datetime_for_cli(datetime.fromisoformat(entry["updated_at"])),
209
238
  "dimensions": {
210
239
  "scaffold_count": len(sorted_scaffolds),
211
240
  "scaffolds": sorted_scaffolds,
@@ -245,14 +274,9 @@ def create_metadata_template_with_project_samples_names(
245
274
  project: str | None = PROJECT_NAME_OPTION,
246
275
  ) -> None:
247
276
  """
248
- Create a template sample metadata file (TSV format) pre-filled with the sample names from the project's VCF files based on the information stored in the project's VCF dimensions cache. Tip: run 'divbase-cli dimensions update' first to ensure that the VCF dimensions areup-to-date.
277
+ Create a template sample metadata file (TSV format) pre-filled with the sample names from the project's VCF files based on the information stored in the project's VCF dimensions cache. Tip: run 'divbase-cli dimensions update' first to ensure that the VCF dimensions are up-to-date.
249
278
  """
250
-
251
- project_config = resolve_project(project_name=project)
252
-
253
- if output_path is None:
254
- output_path = Path.cwd() / f"sample_metadata_{project_config.name}.tsv"
255
-
279
+ project_config = resolve_and_authenticate_project(project_name=project)
256
280
  response = make_authenticated_request(
257
281
  method="GET",
258
282
  divbase_base_url=project_config.divbase_url,
@@ -266,12 +290,14 @@ def create_metadata_template_with_project_samples_names(
266
290
  )
267
291
 
268
292
  if sample_count == 0:
269
- # Fallback in case there are no samples in the dimensions index. If no dimensions entry for the project
293
+ # Fallback in case there are no samples in the dimensions cache. If no dimensions entry for the project
270
294
  # VCFDimensionsEntryMissingError will be returned. But for some reason, there are no samples in the VCF, this will catch that.
271
295
  print("No samples found for this project. No file written.")
272
296
  return
273
297
 
274
- # Check if file exists and prompt user for confirmation
298
+ if output_path is None:
299
+ output_path = Path.cwd() / f"sample_metadata_{project_config.name}.tsv"
300
+
275
301
  if output_path.exists():
276
302
  overwrite = typer.confirm(f"File '{output_path}' already exists. Do you want to overwrite it?")
277
303
  if not overwrite:
@@ -279,7 +305,7 @@ def create_metadata_template_with_project_samples_names(
279
305
  return
280
306
 
281
307
  with open(output_path, mode="w", newline="") as tsvfile:
282
- writer = csv.writer(tsvfile, delimiter="\t")
308
+ writer = csv.writer(tsvfile, delimiter="\t", lineterminator="\n")
283
309
  writer.writerow(["#Sample_ID"])
284
310
  for sample in unique_sample_names_sorted:
285
311
  writer.writerow([sample])
@@ -311,10 +337,8 @@ def validate_metadata_template_versus_dimensions_and_formatting_constraints(
311
337
  """
312
338
  # Client-side validation of a sidecar metadata TSV file, intended to be run before upload to DivBase.
313
339
  # Uses the SharedMetadataValidator (that is also used on the server-side) which checks for formatting errors and also validates that the sample names
314
- # in the TSV file match the sample names in the dimensions index for the project
315
-
316
- project_config = resolve_project(project_name=project)
317
-
340
+ # in the TSV file match the sample names in the dimensions cache for the project
341
+ project_config = resolve_and_authenticate_project(project_name=project)
318
342
  print(f"Validating local metadata file: {input_path}")
319
343
  print(f"Project: {project_config.name}\n")
320
344
 
@@ -388,7 +412,8 @@ def validate_metadata_template_versus_dimensions_and_formatting_constraints(
388
412
 
389
413
  if not errors and not warnings:
390
414
  print(
391
- "[green bold]Validation passed![/green bold] The metadata file meets all DivBase requirements. The file is ready to be uploaded to your DivBase project with 'divbase-cli files upload'"
415
+ "[green bold]Validation passed![/green bold] The metadata file meets all DivBase requirements. "
416
+ f"The file is ready to be uploaded to your DivBase project with the command:\n 'divbase-cli files upload {input_path}'"
392
417
  )
393
418
  elif errors:
394
419
  print("[red bold]Validation failed![/red bold] Please fix the errors above before uploading.")
@@ -396,8 +421,6 @@ def validate_metadata_template_versus_dimensions_and_formatting_constraints(
396
421
  else:
397
422
  print("[yellow bold]Validation passed with warnings![/yellow bold] Review the warnings above.")
398
423
 
399
- # TODO: Add information about how to upload the validated metadata file to DivBase
400
-
401
424
 
402
425
  def _truncate_sample_names_in_entry(entry: dict, sample_names_limit: int) -> None:
403
426
  """