diff --git a/docs/src/cudo_compute/cudo_api.py b/docs/src/cudo_compute/cudo_api.py index 9f4ee71..58b82e6 100644 --- a/docs/src/cudo_compute/cudo_api.py +++ b/docs/src/cudo_compute/cudo_api.py @@ -1,5 +1,7 @@ import cudo_compute as cudo import os +import importlib.metadata + home = os.path.expanduser("~") @@ -17,6 +19,13 @@ def client(): configuration.host = "https://rest.compute.cudo.org" client = cudo.ApiClient(configuration) + version = '' + try: + version = importlib.metadata.version('cudo-compute') + except: + pass + + client.user_agent = 'cudo-compute-python-client/'+version return client, None @@ -31,7 +40,10 @@ def get_api_key(): def get_project_id(): key_config, context_config, error = cudo.AuthConfig.load_config(home + '/.config/cudo/cudo.yml', "") if not error: - return context_config['project'], None + if 'project' in context_config: + return context_config['project'], None + else: + return None, Exception('No project set in configuration (cudo.yml)') else: return None, error @@ -43,6 +55,14 @@ def project_id(): return '' +def project_id_throwable(): + p, e = get_project_id() + if e is None: + return p + else: + raise e + + # APIs def api_keys(): c, err = client() diff --git a/helpers/cudo_api.py b/helpers/cudo_api.py index 8eca7f5..aeb3cb5 100644 --- a/helpers/cudo_api.py +++ b/helpers/cudo_api.py @@ -1,5 +1,6 @@ import cudo_compute as cudo import os +import importlib.metadata home = os.path.expanduser("~") @@ -17,6 +18,13 @@ def client(): configuration.host = "https://rest.compute.cudo.org" client = cudo.ApiClient(configuration) + version = '' + try: + version = importlib.metadata.version('cudo-compute') + except: + pass + + client.user_agent = 'cudo-compute-python-client/' + version return client, None diff --git a/pyproject.toml b/pyproject.toml index 7209a0e..3530cf2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "cudo-compute" -version = "0.1.10" +version = "0.1.13" authors = [ { name = "Cudo Ventures", email = "dev@cudoventures.com" }, ]