1- import importlib .metadata
21import json
32import logging
43import os
54import sys
65from pathlib import Path
76
8- import requests
97from cirro_api_client .v1 .models import UploadDatasetRequest , Status , Executor
108
119from cirro .cirro_client import CirroApi
3937def run_list_datasets (input_params : ListArguments , interactive = False ):
4038 """List the datasets available in a particular project."""
4139 _check_configure ()
42- _check_version ()
4340 cirro = CirroApi ()
4441 logger .info (f"Collecting data from { cirro .configuration .base_url } " )
4542 projects = cirro .projects .list ()
@@ -66,7 +63,6 @@ def run_list_datasets(input_params: ListArguments, interactive=False):
6663
6764def run_ingest (input_params : UploadArguments , interactive = False ):
6865 _check_configure ()
69- _check_version ()
7066 cirro = CirroApi ()
7167 logger .info (f"Collecting data from { cirro .configuration .base_url } " )
7268 processes = cirro .processes .list (process_type = Executor .INGEST )
@@ -125,7 +121,6 @@ def run_ingest(input_params: UploadArguments, interactive=False):
125121
126122def run_download (input_params : DownloadArguments , interactive = False ):
127123 _check_configure ()
128- _check_version ()
129124 cirro = CirroApi ()
130125 logger .info (f"Collecting data from { cirro .configuration .base_url } " )
131126
@@ -182,7 +177,6 @@ def run_download(input_params: DownloadArguments, interactive=False):
182177
183178def run_upload_reference (input_params : UploadReferenceArguments , interactive = False ):
184179 _check_configure ()
185- _check_version ()
186180 cirro = CirroApi ()
187181 logger .info (f"Collecting data from { cirro .configuration .base_url } " )
188182
@@ -207,7 +201,6 @@ def run_upload_reference(input_params: UploadReferenceArguments, interactive=Fal
207201
208202
209203def run_configure ():
210- _check_version ()
211204 auth_method , base_url , auth_method_config , enable_additional_checksum = gather_auth_config ()
212205 save_user_config (UserConfig (auth_method = auth_method ,
213206 auth_method_config = auth_method_config ,
@@ -221,7 +214,6 @@ def run_create_pipeline_config(input_params: CreatePipelineConfigArguments, inte
221214 Creates the pipeline configuration files for the CLI.
222215 This is a placeholder function that can be expanded in the future.
223216 """
224- _check_version ()
225217 logger .info ("Creating pipeline configuration files..." )
226218
227219 if interactive :
@@ -277,27 +269,6 @@ def _check_configure():
277269 run_configure ()
278270
279271
280- def _check_version ():
281- """
282- Prompts the user to update their package version if needed
283- """
284- yellow_color = '\033 [93m'
285- reset_color = '\033 [0m'
286-
287- try :
288- current_version = importlib .metadata .version ('cirro' )
289- response = requests .get ("https://pypi.org/pypi/cirro/json" )
290- response .raise_for_status ()
291- latest_version = response .json ()["info" ]["version" ]
292-
293- if current_version != latest_version :
294- print (f"{ yellow_color } Warning:{ reset_color } Cirro version { current_version } "
295- f"is out of date. Update to { latest_version } with 'pip install cirro --upgrade'." )
296-
297- except Exception :
298- return
299-
300-
301272def handle_error (e : Exception ):
302273 logger .error (f"{ e .__class__ .__name__ } : { e } " )
303274 sys .exit (1 )
0 commit comments