-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
154a726
commit 3f3e158
Showing
10 changed files
with
121 additions
and
277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import cudo_compute as client | ||
def get_client(): | ||
configuration = client.Configuration() | ||
# key, err = config.get_api_key() | ||
|
||
# if err != None: | ||
# return None, err | ||
|
||
configuration.api_key['Authorization'] = "derp" | ||
# configuration.debug = True | ||
configuration.api_key_prefix['Authorization'] = 'Bearer' | ||
configuration.host = "https://rest.compute.cudo.org" | ||
|
||
sclient = client.ApiClient(configuration) | ||
vms_api_client = client.VirtualMachinesApi(sclient) | ||
return vms_api_client, None | ||
|
||
def machine_types(gpu_model, mem_gib, vcpu_count, gpu_count): | ||
try: | ||
c, e = get_client() | ||
types = c.list_vm_machine_types(mem_gib, vcpu_count, gpu=gpu_count, gpu_model=gpu_model) | ||
types_dict = types.to_dict() | ||
return types_dict | ||
except Exception as e: # TODO what to do with errors ? | ||
raise e | ||
|
||
|
||
t = machine_types("",4,4,0) | ||
print(t) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build" | |
|
||
[project] | ||
name = "cudo-compute" | ||
version = "0.0.3" | ||
version = "0.0.4" | ||
authors = [ | ||
{ name = "Cudo Ventures", email = "[email protected]" }, | ||
] | ||
|
@@ -20,6 +20,7 @@ classifiers = [ | |
dependencies = [ | ||
"six>=1.0.0", | ||
"urllib3>=1.10.0", | ||
"certifi>=2023.0.0", | ||
] | ||
|
||
[project.urls] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import yaml | ||
import os | ||
|
||
home = os.path.expanduser("~") | ||
|
||
|
||
def load_config(path, context_name): | ||
key_config = None | ||
context_config = None | ||
error = None | ||
|
||
with open(path, 'r') as file: | ||
config_data = yaml.safe_load(file) | ||
|
||
if config_data['configVersion'] != "v0": | ||
error = Exception("Only config version v0 is supported") | ||
return key_config, context_config, error | ||
|
||
if not context_name: | ||
if 'current-context' in config_data: | ||
context_name = config_data['current-context'] | ||
else: | ||
return key_config, context_config, Exception("No current context selected") | ||
|
||
if 'contexts' in config_data: | ||
for context_data in config_data['contexts']: | ||
if context_data['name'] == context_name: | ||
context_config = context_data | ||
break | ||
|
||
if not context_config: | ||
error = Exception("Context not found") | ||
return key_config, context_config, error | ||
|
||
if 'keys' in config_data: | ||
for key_data in config_data['keys']: | ||
if key_data['name'] == context_config['key']: | ||
key_config = key_data | ||
|
||
if not key_config: | ||
error = Exception("Key not found") | ||
|
||
return key_config, context_config, error | ||
|
||
|
||
def get_api_key(): | ||
key_config, context_config, error = load_config(home + '/.config/cudo/cudo.yml', "") | ||
if not error: | ||
return key_config['key'], None | ||
else: | ||
return None, error | ||
|
||
|
||
def get_project(): | ||
key_config, context_config, error = load_config(home + '/.config/cudo/cudo.yml', "") | ||
if not error: | ||
return context_config['project'], None | ||
else: | ||
return None, error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import src.cudo_compute as cudo | ||
def get_client(): | ||
configuration = cudo.Configuration() | ||
key, err = cudo.AuthConfig.get_api_key() | ||
|
||
if err != None: | ||
return None, err | ||
|
||
configuration.api_key['Authorization'] = key | ||
# configuration.debug = True | ||
configuration.api_key_prefix['Authorization'] = 'Bearer' | ||
configuration.host = "https://rest.compute.cudo.org" | ||
|
||
sclient = cudo.ApiClient(configuration) | ||
vms_api_client = cudo.VirtualMachinesApi(sclient) | ||
return vms_api_client, None |
File renamed without changes.