Skip to content

Commit 319242e

Browse files
committed
chore: linting with black
1 parent 5537d62 commit 319242e

File tree

3 files changed

+40
-24
lines changed

3 files changed

+40
-24
lines changed

datatorch/api/client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import List, Union, cast, IO
2-
import requests, glob, os #, cgi
2+
import requests, glob, os # , cgi
33
from urllib.parse import urlencode
44

55
from gql import Client as GqlClient, gql
@@ -180,7 +180,9 @@ def download_file(
180180
filename_param = headers.get_param("filename")
181181
# Ensure filename is a string
182182
if isinstance(filename_param, tuple):
183-
filename = filename_param[0] or "" # Use the first element of the tuple if present
183+
filename = (
184+
filename_param[0] or ""
185+
) # Use the first element of the tuple if present
184186
elif isinstance(filename_param, str):
185187
filename = filename_param
186188
else:

datatorch/cli/upload/folder.py

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ def folder(folder_path, project_id):
1313
"""Bulk upload files to a specified project."""
1414

1515
# Get the list of files to upload
16-
files = [f for f in os.listdir(folder_path)
17-
if os.path.isfile(os.path.join(folder_path, f))]
16+
files = [
17+
f
18+
for f in os.listdir(folder_path)
19+
if os.path.isfile(os.path.join(folder_path, f))
20+
]
1821
total_files = len(files)
1922

2023
if total_files == 0:
@@ -27,8 +30,7 @@ def folder(folder_path, project_id):
2730
api_url = user_settings.api_url
2831

2932
if not api_key or not api_url:
30-
click.echo("You are not logged in. "
31-
"Please log in using the `login` command.")
33+
click.echo("You are not logged in. " "Please log in using the `login` command.")
3234
return
3335

3436
# Initialize the API client
@@ -45,8 +47,7 @@ def folder(folder_path, project_id):
4547
project = client.project(project_id)
4648
click.echo(f"Retrieved project: {project.name}")
4749
except Exception as e:
48-
click.echo(f"Error: Unable to retrieve "
49-
f"project with ID '{project_id}'. {e}")
50+
click.echo(f"Error: Unable to retrieve " f"project with ID '{project_id}'. {e}")
5051
return
5152

5253
# Display available dataset
@@ -65,13 +66,20 @@ def folder(folder_path, project_id):
6566
)
6667
if 1 <= choice <= len(datasets):
6768
selected_dataset = datasets[choice - 1]
68-
click.echo(f"Selected Dataset: {selected_dataset.name} (ID: {selected_dataset.id}")
69+
click.echo(
70+
f"Selected Dataset: {selected_dataset.name} (ID: {selected_dataset.id}"
71+
)
6972
else:
70-
click.echo(f"Invalid choice. Please select a number between 1 and {len(datasets)}")
73+
click.echo(
74+
f"Invalid choice. Please select a number between 1 and {len(datasets)}"
75+
)
7176
else:
7277
# No datasets found, as if user want to continue with global upload
73-
continue_upload = click.confirm("No datasets found for this project"
74-
"Do you want to continue with global upload?", default=False)
78+
continue_upload = click.confirm(
79+
"No datasets found for this project"
80+
"Do you want to continue with global upload?",
81+
default=False,
82+
)
7583
if not continue_upload:
7684
click.echo("Ending...")
7785
return
@@ -88,8 +96,7 @@ def folder(folder_path, project_id):
8896

8997
click.echo("\nAvailable Storages:")
9098
for idx, storage_link in enumerate(storage_links):
91-
click.echo(f"{idx + 1}. {storage_link.name} "
92-
f"(ID: {storage_link.id})")
99+
click.echo(f"{idx + 1}. {storage_link.name} " f"(ID: {storage_link.id})")
93100

94101
# Prompt user to select a storage link
95102
choice = click.prompt(
@@ -100,11 +107,15 @@ def folder(folder_path, project_id):
100107
if 1 <= choice <= len(storage_links):
101108
selected_storage_link = storage_links[choice - 1]
102109
else:
103-
click.echo(f"Invalid choice. Please select a number between 1 and {len(storage_links)}.")
110+
click.echo(
111+
f"Invalid choice. Please select a number between 1 and {len(storage_links)}."
112+
)
104113
return
105114

106-
click.echo(f"Selected Storage: {selected_storage_link.name} "
107-
f"(ID: {selected_storage_link.id})")
115+
click.echo(
116+
f"Selected Storage: {selected_storage_link.name} "
117+
f"(ID: {selected_storage_link.id})"
118+
)
108119
except Exception as e:
109120
click.echo(f"Error retrieving storage: {e}")
110121
return

examples/upload_files.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import os
22
import datatorch as dt
33

4-
api = dt.api.ApiClient('your-api-key')
5-
proj = api.project('user-name/project-name')
6-
dset = proj.dataset('data-set-name')
4+
api = dt.api.ApiClient("your-api-key")
5+
proj = api.project("user-name/project-name")
6+
dset = proj.dataset("data-set-name")
77

8-
folder_to_upload = 'uploadme'
9-
upload_to_storage_id = 'your-storage-id'
8+
folder_to_upload = "uploadme"
9+
upload_to_storage_id = "your-storage-id"
1010

1111
# Get all the file names in the folder
12-
files = [f for f in os.listdir(folder_to_upload)
13-
if os.path.isfile(os.path.join(folder_to_upload, f))]
12+
files = [
13+
f
14+
for f in os.listdir(folder_to_upload)
15+
if os.path.isfile(os.path.join(folder_to_upload, f))
16+
]
1417

1518
# Upload files to the selected storage and dataset using their IDs
1619
try:

0 commit comments

Comments
 (0)