From 8dad870d5545edad992e29e50aa5427694d4af3e Mon Sep 17 00:00:00 2001 From: Hippolyte Blot Date: Fri, 15 Nov 2024 14:36:50 +0100 Subject: [PATCH 01/10] Adding set_vip_url function --- src/vip_client/utils/vip.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/vip_client/utils/vip.py b/src/vip_client/utils/vip.py index 3e87153..21c4c4f 100644 --- a/src/vip_client/utils/vip.py +++ b/src/vip_client/utils/vip.py @@ -20,6 +20,11 @@ # API URL __PREFIX = "https://vip.creatis.insa-lyon.fr/rest/" +def set_vip_api_url(new_prefix: str) -> None: + """Change the API prefix""" + global __PREFIX + __PREFIX = new_prefix + # API key __apikey = None __headers = {'apikey': __apikey} From b7f54950ef52456dbba408b1acdf2d054eb0d501 Mon Sep 17 00:00:00 2001 From: Hippolyte Blot Date: Tue, 11 Feb 2025 15:56:38 +0100 Subject: [PATCH 02/10] fix bad route used to check api key --- src/vip_client/utils/vip.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vip_client/utils/vip.py b/src/vip_client/utils/vip.py index 21c4c4f..cafc67c 100644 --- a/src/vip_client/utils/vip.py +++ b/src/vip_client/utils/vip.py @@ -85,7 +85,7 @@ def setApiKey(value) -> bool: Return True is correct apikey, False otherwise. Raise an error if an other problems occured """ - url = __PREFIX + 'plateform' + url = __PREFIX + 'platform' head_test = { 'apikey': value, } From 0a1b88319fabec1321458254e050871dcc657fa4 Mon Sep 17 00:00:00 2001 From: Hippolyte Blot Date: Tue, 11 Feb 2025 15:58:17 +0100 Subject: [PATCH 03/10] allow user to choose the url of the girder instance --- src/vip_client/classes/VipCI.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/vip_client/classes/VipCI.py b/src/vip_client/classes/VipCI.py index 7b8cb7a..c06c5fe 100644 --- a/src/vip_client/classes/VipCI.py +++ b/src/vip_client/classes/VipCI.py @@ -51,13 +51,8 @@ class VipCI(VipLauncher): # Default backup location # (set to None to avoid saving and loading backup files) _BACKUP_LOCATION = "girder" - - # --- New Attributes --- - - # Prefix that defines a Girder ID - _GIRDER_ID_PREFIX = "pilotGirder" - # Grider portal - _GIRDER_PORTAL = 'https://pilot-warehouse.creatis.insa-lyon.fr/api/v1' + + ################# ################ Main Properties ################## @@ -137,7 +132,10 @@ def __init__( # Login to VIP and Girder @classmethod - def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, **kwargs) -> VipCI: + def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, + girder_portal='https://pilot-warehouse.creatis.insa-lyon.fr/api/v1', + girder_id_prefix="pilotGirder", + **kwargs) -> VipCI: """ Handshakes with VIP using your own API key. Returns a class instance which properties can be provided as keyword arguments. @@ -162,7 +160,9 @@ def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, # Restore the verbose state cls._VERBOSE = verbose # Instantiate a Girder client - cls._girder_client = girder_client.GirderClient(apiUrl=cls._GIRDER_PORTAL) + cls._girder_client = girder_client.GirderClient(apiUrl=girder_portal) + # Set the Girder ID prefix + cls._GIRDER_ID_PREFIX = girder_id_prefix # Check if `girder_key` is in a local file or environment variable true_key = cls._get_api_key(girder_key) # Authenticate with Girder API key From 15a0600f03e3a09eae5c423a41e33f3b3a4a4536 Mon Sep 17 00:00:00 2001 From: Hippolyte Blot Date: Wed, 12 Feb 2025 17:47:21 +0100 Subject: [PATCH 04/10] better name for girder url --- src/vip_client/classes/VipCI.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vip_client/classes/VipCI.py b/src/vip_client/classes/VipCI.py index c06c5fe..e79f6d6 100644 --- a/src/vip_client/classes/VipCI.py +++ b/src/vip_client/classes/VipCI.py @@ -133,7 +133,7 @@ def __init__( # Login to VIP and Girder @classmethod def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, - girder_portal='https://pilot-warehouse.creatis.insa-lyon.fr/api/v1', + girder_api_url='https://pilot-warehouse.creatis.insa-lyon.fr/api/v1', girder_id_prefix="pilotGirder", **kwargs) -> VipCI: """ @@ -160,7 +160,7 @@ def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, # Restore the verbose state cls._VERBOSE = verbose # Instantiate a Girder client - cls._girder_client = girder_client.GirderClient(apiUrl=girder_portal) + cls._girder_client = girder_client.GirderClient(apiUrl=girder_api_url) # Set the Girder ID prefix cls._GIRDER_ID_PREFIX = girder_id_prefix # Check if `girder_key` is in a local file or environment variable From 300c04fe637b683a362a5ce6f356f01e31589923 Mon Sep 17 00:00:00 2001 From: Hippolyte Blot Date: Thu, 13 Feb 2025 17:26:32 +0100 Subject: [PATCH 05/10] Allow user to change vip portal url when using classes --- src/vip_client/classes/VipCI.py | 5 +++-- src/vip_client/classes/VipLauncher.py | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/vip_client/classes/VipCI.py b/src/vip_client/classes/VipCI.py index e79f6d6..d47e226 100644 --- a/src/vip_client/classes/VipCI.py +++ b/src/vip_client/classes/VipCI.py @@ -52,6 +52,7 @@ class VipCI(VipLauncher): # (set to None to avoid saving and loading backup files) _BACKUP_LOCATION = "girder" + _GIRDER_ID_PREFIX = "pilotGirder" ################# @@ -134,7 +135,7 @@ def __init__( @classmethod def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, girder_api_url='https://pilot-warehouse.creatis.insa-lyon.fr/api/v1', - girder_id_prefix="pilotGirder", + girder_id_prefix=None, **kwargs) -> VipCI: """ Handshakes with VIP using your own API key. @@ -162,7 +163,7 @@ def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, # Instantiate a Girder client cls._girder_client = girder_client.GirderClient(apiUrl=girder_api_url) # Set the Girder ID prefix - cls._GIRDER_ID_PREFIX = girder_id_prefix + cls._GIRDER_ID_PREFIX = girder_id_prefix if girder_id_prefix is not None else cls._GIRDER_ID_PREFIX # Check if `girder_key` is in a local file or environment variable true_key = cls._get_api_key(girder_key) # Authenticate with Girder API key diff --git a/src/vip_client/classes/VipLauncher.py b/src/vip_client/classes/VipLauncher.py index dc63315..43fd08f 100644 --- a/src/vip_client/classes/VipLauncher.py +++ b/src/vip_client/classes/VipLauncher.py @@ -371,7 +371,8 @@ def __init__( # ($A.1) Login to VIP @classmethod - def init(cls, api_key="VIP_API_KEY", verbose=True, **kwargs) -> VipLauncher: + def init(cls, api_key="VIP_API_KEY", verbose=True, vip_portal_url=None, + **kwargs) -> VipLauncher: """ Handshakes with VIP using your own API key. Returns a class instance which properties can be provided as keyword arguments. @@ -391,6 +392,8 @@ def init(cls, api_key="VIP_API_KEY", verbose=True, **kwargs) -> VipLauncher: """ # Set the default verbose mode for all sessions cls._VERBOSE = verbose + # Set the VIP portal URL + cls._VIP_PORTAL = vip_portal_url if vip_portal_url else cls._VIP_PORTAL # Check if `api_key` is in a local file or environment variable true_key = cls._get_api_key(api_key) # Set User API key From 5ecc9c2cf0ecfcb9f434e92437a2b0138da1a9fc Mon Sep 17 00:00:00 2001 From: Hippolyte Blot Date: Thu, 13 Feb 2025 17:50:23 +0100 Subject: [PATCH 06/10] setting new vip url with utils/vip.py --- src/vip_client/classes/VipLauncher.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vip_client/classes/VipLauncher.py b/src/vip_client/classes/VipLauncher.py index 43fd08f..7fc6b40 100644 --- a/src/vip_client/classes/VipLauncher.py +++ b/src/vip_client/classes/VipLauncher.py @@ -49,7 +49,7 @@ class VipLauncher(): # Default file name to save session properties _SAVE_FILE = "session_data.json" # Vip portal - _VIP_PORTAL = "https://vip.creatis.insa-lyon.fr/" + _VIP_PORTAL = "https://vip.creatis.insa-lyon.fr/rest/" # Mail address for support _VIP_SUPPORT = "vip-support@creatis.insa-lyon.fr" # Regular expression for invalid characters (i.e. all except valid characters) @@ -399,6 +399,7 @@ def init(cls, api_key="VIP_API_KEY", verbose=True, vip_portal_url=None, # Set User API key try: # setApiKey() may return False + vip.set_vip_api_url(cls._VIP_PORTAL) assert vip.setApiKey(true_key), \ f"(!) Unable to set the VIP API key: {true_key}.\nPlease check the key or retry later." except RuntimeError as vip_error: From 9d6136f45f1e11ae6420907ccb8e598527b6e3c0 Mon Sep 17 00:00:00 2001 From: Hippolyte Blot Date: Fri, 14 Feb 2025 17:25:46 +0100 Subject: [PATCH 07/10] check for empty file and code refactor --- src/vip_client/classes/VipCI.py | 6 +++++- src/vip_client/classes/VipLauncher.py | 26 +++++++++++++++----------- src/vip_client/classes/VipSession.py | 7 +++++-- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/vip_client/classes/VipCI.py b/src/vip_client/classes/VipCI.py index d47e226..f924503 100644 --- a/src/vip_client/classes/VipCI.py +++ b/src/vip_client/classes/VipCI.py @@ -52,7 +52,10 @@ class VipCI(VipLauncher): # (set to None to avoid saving and loading backup files) _BACKUP_LOCATION = "girder" + # Prefix that defines a Girder ID _GIRDER_ID_PREFIX = "pilotGirder" + # Grider portal + _GIRDER_PORTAL = 'https://pilot-warehouse.creatis.insa-lyon.fr/api/v1' ################# @@ -134,7 +137,7 @@ def __init__( # Login to VIP and Girder @classmethod def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, - girder_api_url='https://pilot-warehouse.creatis.insa-lyon.fr/api/v1', + girder_api_url=None, girder_id_prefix=None, **kwargs) -> VipCI: """ @@ -164,6 +167,7 @@ def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, cls._girder_client = girder_client.GirderClient(apiUrl=girder_api_url) # Set the Girder ID prefix cls._GIRDER_ID_PREFIX = girder_id_prefix if girder_id_prefix is not None else cls._GIRDER_ID_PREFIX + cls._GIRDER_PORTAL = girder_api_url if girder_api_url is not None else cls._GIRDER_PORTAL # Check if `girder_key` is in a local file or environment variable true_key = cls._get_api_key(girder_key) # Authenticate with Girder API key diff --git a/src/vip_client/classes/VipLauncher.py b/src/vip_client/classes/VipLauncher.py index 7fc6b40..9fcb1de 100644 --- a/src/vip_client/classes/VipLauncher.py +++ b/src/vip_client/classes/VipLauncher.py @@ -1645,6 +1645,7 @@ def _check_input_values(self, input_settings: dict, location: str) -> None: self._check_invalid_input(input_settings, self._pipeline_def['parameters']) wrong_type_inputs = [] + missing_files = [] for param in self._pipeline_def['parameters']: name = param['name'] # Check only defined inputs @@ -1654,11 +1655,10 @@ def _check_input_values(self, input_settings: dict, location: str) -> None: # If input is a File, check file(s) existence if param["type"] == "File": # Ensure every file exists at `location` - missing_file = self._first_missing_file(value, location) + missing_file = self._missing_file(value, location) if missing_file: - raise FileNotFoundError( - f"Parameter '{name}': The following file is missing in the {location.upper()} file system: {missing_file}" - ) + missing_files.append(name) + continue if param["type"] == "Boolean": if value not in ["true", "false"]: wrong_type_inputs.append(name) @@ -1670,6 +1670,10 @@ def _check_input_values(self, input_settings: dict, location: str) -> None: raise ValueError( f"Wrong type(s) for parameter(s): {', '.join(sorted(wrong_type_inputs))}" ) + if missing_files: + raise FileNotFoundError( + f"Missing file(s) for parameter(s): {', '.join(sorted(missing_files))}" + ) # ------------------------------------------------ @@ -1717,21 +1721,21 @@ def _invalid_chars_for_vip(cls, value) -> list: # Function to assert file existence in the input settings @classmethod - def _first_missing_file(cls, value, location: str) -> str: + def _missing_file(cls, value, location: str) -> str: """ - Returns the path the first non-existent file in `value` (None by default). + Returns true if the file `value` does not exist at `location`. - `value` can contain a single file path or a list of paths. - `location` refers to the storage infrastructure (e.g., "vip") to feed in cls._exists(). """ # Case : list of files if isinstance(value, list): - for file in value : - if cls._first_missing_file(value=file, location=location) is not None: + for file in value : + if not cls._exists(file, location=location): return file - return None - # Case: single file + # Case : single file else: - return value if not cls._exists(path=value, location=location) else None + if not cls._exists(value, location=location): + return value # ------------------------------------------------ ######################################## diff --git a/src/vip_client/classes/VipSession.py b/src/vip_client/classes/VipSession.py index 9047345..3237d30 100644 --- a/src/vip_client/classes/VipSession.py +++ b/src/vip_client/classes/VipSession.py @@ -684,11 +684,12 @@ def _path_to_delete(self) -> dict: def _exists(cls, path: PurePath, location="local") -> bool: """ Checks existence of a distant (`location`="vip") or local (`location`="local") resource. - `path` can be a string or path-like object. + `path` can be a string or path-like object. If `location` is "local", empty folders are + considered as non-existent. """ # Check path existence in `location` if location=="local": - return os.path.exists(path) + return os.path.exists(path) and os.path.isdir(path) and os.listdir(path) else: return super()._exists(path=path, location=location) # ------------------------------------------------ @@ -832,6 +833,8 @@ def _upload_dir(self, local_path: Path, vip_path: PurePosixPath) -> list: for local_file in files_to_upload : nFile+=1 # Get the file size (if possible) + if local_file.stat().st_size == 0: + raise ValueError(f"File {local_file} is empty.") try: size = f"{local_file.stat().st_size/(1<<20):,.1f}MB" except: size = "unknown size" # Display the current file From 65204074e6679614099601d725a0fd109f19b8ce Mon Sep 17 00:00:00 2001 From: Hippolyte Blot Date: Mon, 17 Feb 2025 09:26:55 +0100 Subject: [PATCH 08/10] Better way to check file size --- src/vip_client/classes/VipSession.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vip_client/classes/VipSession.py b/src/vip_client/classes/VipSession.py index 3237d30..7edffe8 100644 --- a/src/vip_client/classes/VipSession.py +++ b/src/vip_client/classes/VipSession.py @@ -351,7 +351,7 @@ def upload_inputs(self, input_dir=None, update_files=True) -> VipSession: raise TypeError(f"Session '{self._session_name}': Please provide an input directory.") # Check local input directory if not self._exists(self._local_input_dir, location="local"): - raise FileNotFoundError(f"Session '{self._session_name}': Input directory does not exist.") + raise FileNotFoundError(f"Session '{self._session_name}': Input directory '{self._local_input_dir}' does not exist.") # Check the local values of `input_settings` before uploading if self._is_defined("_input_settings"): self._print("Checking references to the dataset within Input Settings ... ", end="", flush=True) @@ -832,10 +832,10 @@ def _upload_dir(self, local_path: Path, vip_path: PurePosixPath) -> list: failures = [] for local_file in files_to_upload : nFile+=1 - # Get the file size (if possible) - if local_file.stat().st_size == 0: - raise ValueError(f"File {local_file} is empty.") - try: size = f"{local_file.stat().st_size/(1<<20):,.1f}MB" + try: + size = local_file.stat().st_size + if size == 0: raise ValueError("Empty file") + size = f"{size/(1<<20):,.1f}MB" except: size = "unknown size" # Display the current file self._print(f"\t[{nFile}/{len(files_to_upload)}] Uploading file: {local_file.name} ({size}) ...", end=" ") From b2a60495ac4f6ddb894887ca4e21e80e78438303 Mon Sep 17 00:00:00 2001 From: Hippolyte Blot Date: Tue, 18 Feb 2025 16:15:27 +0100 Subject: [PATCH 09/10] refactor --- src/vip_client/classes/VipCI.py | 17 +++++++++----- src/vip_client/classes/VipLauncher.py | 32 ++++++++++++++++----------- src/vip_client/classes/VipSession.py | 11 +++++---- src/vip_client/utils/vip.py | 2 +- 4 files changed, 36 insertions(+), 26 deletions(-) diff --git a/src/vip_client/classes/VipCI.py b/src/vip_client/classes/VipCI.py index f924503..456bd7b 100644 --- a/src/vip_client/classes/VipCI.py +++ b/src/vip_client/classes/VipCI.py @@ -136,10 +136,15 @@ def __init__( # Login to VIP and Girder @classmethod - def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, - girder_api_url=None, - girder_id_prefix=None, - **kwargs) -> VipCI: + def init( + cls, + vip_key="VIP_API_KEY", + girder_key="GIRDER_API_KEY", + verbose=True, + girder_api_url=None, + girder_id_prefix=None, + **kwargs + ) -> VipCI: """ Handshakes with VIP using your own API key. Returns a class instance which properties can be provided as keyword arguments. @@ -163,11 +168,11 @@ def init(cls, vip_key="VIP_API_KEY", girder_key="GIRDER_API_KEY", verbose=True, super().init(api_key=vip_key, verbose=False) # Restore the verbose state cls._VERBOSE = verbose - # Instantiate a Girder client - cls._girder_client = girder_client.GirderClient(apiUrl=girder_api_url) # Set the Girder ID prefix cls._GIRDER_ID_PREFIX = girder_id_prefix if girder_id_prefix is not None else cls._GIRDER_ID_PREFIX cls._GIRDER_PORTAL = girder_api_url if girder_api_url is not None else cls._GIRDER_PORTAL + # Instantiate a Girder client + cls._girder_client = girder_client.GirderClient(apiUrl=girder_api_url) # Check if `girder_key` is in a local file or environment variable true_key = cls._get_api_key(girder_key) # Authenticate with Girder API key diff --git a/src/vip_client/classes/VipLauncher.py b/src/vip_client/classes/VipLauncher.py index 9fcb1de..617bc6c 100644 --- a/src/vip_client/classes/VipLauncher.py +++ b/src/vip_client/classes/VipLauncher.py @@ -49,7 +49,7 @@ class VipLauncher(): # Default file name to save session properties _SAVE_FILE = "session_data.json" # Vip portal - _VIP_PORTAL = "https://vip.creatis.insa-lyon.fr/rest/" + _VIP_PORTAL = "https://vip.creatis.insa-lyon.fr/" # Mail address for support _VIP_SUPPORT = "vip-support@creatis.insa-lyon.fr" # Regular expression for invalid characters (i.e. all except valid characters) @@ -1655,9 +1655,9 @@ def _check_input_values(self, input_settings: dict, location: str) -> None: # If input is a File, check file(s) existence if param["type"] == "File": # Ensure every file exists at `location` - missing_file = self._missing_file(value, location) - if missing_file: - missing_files.append(name) + missing_files_found = self._missing_file(value, location) + if missing_files_found: + missing_files.extend(missing_files_found) continue if param["type"] == "Boolean": if value not in ["true", "false"]: @@ -1721,21 +1721,27 @@ def _invalid_chars_for_vip(cls, value) -> list: # Function to assert file existence in the input settings @classmethod - def _missing_file(cls, value, location: str) -> str: + def _missing_file(cls, value, location: str) -> list[str]: """ - Returns true if the file `value` does not exist at `location`. - - `value` can contain a single file path or a list of paths. - - `location` refers to the storage infrastructure (e.g., "vip") to feed in cls._exists(). + Returns a list of missing files for `value` at `location`. + + - `value` can be either a single file path or a list of paths. + - `location` refers to the storage infrastructure (e.g., "vip") used by cls._exists(). """ - # Case : list of files + missing_files = [] + + # Case: list of files if isinstance(value, list): - for file in value : + for file in value: if not cls._exists(file, location=location): - return file - # Case : single file + missing_files.append(file) + # Case: single file else: if not cls._exists(value, location=location): - return value + missing_files.append(value) + + return missing_files + # ------------------------------------------------ ######################################## diff --git a/src/vip_client/classes/VipSession.py b/src/vip_client/classes/VipSession.py index 7edffe8..00ad805 100644 --- a/src/vip_client/classes/VipSession.py +++ b/src/vip_client/classes/VipSession.py @@ -350,7 +350,7 @@ def upload_inputs(self, input_dir=None, update_files=True) -> VipSession: elif not self._is_defined("_local_input_dir"): raise TypeError(f"Session '{self._session_name}': Please provide an input directory.") # Check local input directory - if not self._exists(self._local_input_dir, location="local"): + if not self._exists(self._local_input_dir, location="local"): raise FileNotFoundError(f"Session '{self._session_name}': Input directory '{self._local_input_dir}' does not exist.") # Check the local values of `input_settings` before uploading if self._is_defined("_input_settings"): @@ -832,11 +832,10 @@ def _upload_dir(self, local_path: Path, vip_path: PurePosixPath) -> list: failures = [] for local_file in files_to_upload : nFile+=1 - try: - size = local_file.stat().st_size - if size == 0: raise ValueError("Empty file") - size = f"{size/(1<<20):,.1f}MB" - except: size = "unknown size" + # Check the file size + size = local_file.stat().st_size + if size == 0: raise ValueError(f"{local_file} is an empty file. Empty file are not supported on VIP") + size = f"{size/(1<<20):,.1f}MB" # Display the current file self._print(f"\t[{nFile}/{len(files_to_upload)}] Uploading file: {local_file.name} ({size}) ...", end=" ") # Upload the file on VIP diff --git a/src/vip_client/utils/vip.py b/src/vip_client/utils/vip.py index cafc67c..37a5f7f 100644 --- a/src/vip_client/utils/vip.py +++ b/src/vip_client/utils/vip.py @@ -23,7 +23,7 @@ def set_vip_api_url(new_prefix: str) -> None: """Change the API prefix""" global __PREFIX - __PREFIX = new_prefix + __PREFIX = new_prefix + "/rest/" # API key __apikey = None From fad044ef52e05aea49d3137c55c8a95c3e6fc721 Mon Sep 17 00:00:00 2001 From: Hippolyte Blot Date: Tue, 25 Feb 2025 15:06:27 +0100 Subject: [PATCH 10/10] Renaming --- src/vip_client/classes/VipLauncher.py | 6 +++--- src/vip_client/utils/vip.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/vip_client/classes/VipLauncher.py b/src/vip_client/classes/VipLauncher.py index 617bc6c..b24804c 100644 --- a/src/vip_client/classes/VipLauncher.py +++ b/src/vip_client/classes/VipLauncher.py @@ -399,7 +399,7 @@ def init(cls, api_key="VIP_API_KEY", verbose=True, vip_portal_url=None, # Set User API key try: # setApiKey() may return False - vip.set_vip_api_url(cls._VIP_PORTAL) + vip.set_vip_url(cls._VIP_PORTAL) assert vip.setApiKey(true_key), \ f"(!) Unable to set the VIP API key: {true_key}.\nPlease check the key or retry later." except RuntimeError as vip_error: @@ -1655,7 +1655,7 @@ def _check_input_values(self, input_settings: dict, location: str) -> None: # If input is a File, check file(s) existence if param["type"] == "File": # Ensure every file exists at `location` - missing_files_found = self._missing_file(value, location) + missing_files_found = self._missing_files(value, location) if missing_files_found: missing_files.extend(missing_files_found) continue @@ -1721,7 +1721,7 @@ def _invalid_chars_for_vip(cls, value) -> list: # Function to assert file existence in the input settings @classmethod - def _missing_file(cls, value, location: str) -> list[str]: + def _missing_files(cls, value, location: str) -> list[str]: """ Returns a list of missing files for `value` at `location`. diff --git a/src/vip_client/utils/vip.py b/src/vip_client/utils/vip.py index 37a5f7f..29ffdd7 100644 --- a/src/vip_client/utils/vip.py +++ b/src/vip_client/utils/vip.py @@ -20,10 +20,10 @@ # API URL __PREFIX = "https://vip.creatis.insa-lyon.fr/rest/" -def set_vip_api_url(new_prefix: str) -> None: +def set_vip_url(vip_portal_url: str) -> None: """Change the API prefix""" global __PREFIX - __PREFIX = new_prefix + "/rest/" + __PREFIX = vip_portal_url + "/rest/" # API key __apikey = None