diff --git a/meorg_client/cli.py b/meorg_client/cli.py index e526ef5..55b7494 100644 --- a/meorg_client/cli.py +++ b/meorg_client/cli.py @@ -286,8 +286,9 @@ def cli_analysis(): # Add file commands cli_file.add_command(file_list) cli_file.add_command(file_upload) -# cli_file.add_command(file_upload_parallel) cli_file.add_command(file_attach) +cli_file.add_command(file_detach_all) + # Add endpoint commands cli_endpoints.add_command(list_endpoints) diff --git a/meorg_client/client.py b/meorg_client/client.py index a28f83d..89e1b4f 100644 --- a/meorg_client/client.py +++ b/meorg_client/client.py @@ -291,10 +291,22 @@ def upload_files( response = self._upload_file(fp, attach_to=attach_to) responses.append(response) else: + + # Disable the auto attach to avoid race condition responses = self._upload_files_parallel( - files, n=n, attach_to=attach_to, progress=progress + files, n=n, attach_to=None, progress=progress ) + if attach_to: + + file_ids = list() + + for response in responses: + file_id = response.get("data").get("files")[0].get("file") + file_ids.append(file_id) + + self.attach_files_to_model_output(id=attach_to, files=file_ids) + return mu.ensure_list(responses) def _upload_file( @@ -503,3 +515,19 @@ def success(self) -> bool: True if successful, False otherwise. """ return self.last_response.status_code in mcc.HTTP_STATUS_SUCCESS_RANGE + + def is_initialised(self, dev: bool = False) -> bool: + """Check if the client is initialised. + NOTE: This does not check the login actually works. + Parameters + ---------- + dev : bool, optional + Use dev credentials, by default False + Returns + ------- + bool + True if initialised, False otherwise. + """ + cred_filename = "credentials.json" if not dev else "credentials-dev.json" + cred_filepath = mu.get_user_data_filepath(cred_filename) + return cred_filepath.exists() diff --git a/pyproject.toml b/pyproject.toml index d6fc847..1fb8475 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,13 +18,14 @@ license = {file="LICENSE"} dynamic = ["version"] # Dependencies -requires-python = ">=3.11" +requires-python = ">=3.9" dependencies = [ "requests>=2.31.0", "requests-mock>=1.11.0", "PyYAML>=6.0.1", "click>=8.1.7", - "pandas>=2.2.2" + "pandas>=2.2.2", + "tqdm>=4.66.5" ] authors = [