-
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
a346b00
commit a9dd6c9
Showing
8 changed files
with
128 additions
and
46 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
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 |
---|---|---|
@@ -1,31 +1,30 @@ | ||
import cudo_compute as cudo | ||
from cudo_compute import cudo_api | ||
import cudo_compute | ||
|
||
|
||
def machine_types(gpu_model, mem_gib, vcpu_count, gpu_count): | ||
try: | ||
client, e = cudo.CudoClient.get_client() | ||
api = cudo.VirtualMachinesApi(client) | ||
api = cudo_api.virtualmachines() | ||
types = api.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: | ||
raise e | ||
|
||
|
||
print(machine_types("",4,4,0)) | ||
print(machine_types("", 4, 4, 0)) | ||
|
||
project_id, e = cudo.AuthConfig.get_project() | ||
print(project_id, e) | ||
print(cudo_api.project_id()) | ||
|
||
def list_instances(): | ||
try: | ||
project_id, e = cudo.AuthConfig.get_project() | ||
client, e = cudo.CudoClient.get_client() | ||
api = cudo.VirtualMachinesApi(client) | ||
vms = api.list_vms(project_id) | ||
api = cudo_api.virtualmachines() | ||
vms = api.list_vms(cudo_api.project_id()) | ||
instances = {} | ||
vms_dict = vms.to_dict() | ||
return vms_dict | ||
except Exception as e: | ||
raise e | ||
|
||
print(list_instances()) | ||
|
||
print(list_instances()) |
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,113 @@ | ||
import cudo_compute as cudo | ||
import os | ||
|
||
home = os.path.expanduser("~") | ||
|
||
|
||
def client(): | ||
configuration = cudo.Configuration() | ||
key, err = get_api_key() | ||
|
||
if err: | ||
return None, err | ||
|
||
configuration.api_key['Authorization'] = key | ||
# configuration.debug = True | ||
configuration.api_key_prefix['Authorization'] = 'Bearer' | ||
configuration.host = "https://rest.compute.cudo.org" | ||
|
||
client = cudo.ApiClient(configuration) | ||
return client, None | ||
|
||
|
||
def get_api_key(): | ||
key_config, context_config, error = cudo.AuthConfig.load_config(home + '/.config/cudo/cudo.yml', "") | ||
if not error: | ||
return key_config['key'], None | ||
else: | ||
return None, error | ||
|
||
|
||
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 | ||
else: | ||
return None, error | ||
|
||
|
||
def project_id(): | ||
p, e = get_project_id() | ||
if e is None: | ||
return p | ||
return '' | ||
|
||
# APIs | ||
def apikeys(): | ||
c, err = client() | ||
if err: | ||
raise Exception(err) | ||
return cudo.APIKeysApi(c) | ||
|
||
|
||
def disks(): | ||
c, err = client() | ||
if err: | ||
raise Exception(err) | ||
return cudo.DisksApi(c) | ||
|
||
|
||
def networks(): | ||
c, err = client() | ||
if err: | ||
raise Exception(err) | ||
return cudo.NetworksApi(c) | ||
|
||
|
||
def objectstorage(): | ||
c, err = client() | ||
if err: | ||
raise Exception(err) | ||
return cudo.ObjectStorageApi(c) | ||
|
||
|
||
def permissions(): | ||
c, err = client() | ||
if err: | ||
raise Exception(err) | ||
return cudo.PermissionsApi(c) | ||
|
||
|
||
def projects(): | ||
c, err = client() | ||
if err: | ||
raise Exception(err) | ||
return cudo.ProjectsApi(c) | ||
|
||
|
||
def sshkeys(): | ||
c, err = client() | ||
if err: | ||
raise Exception(err) | ||
return cudo.SSHKeysApi(c) | ||
|
||
|
||
def search(): | ||
c, err = client() | ||
if err: | ||
raise Exception(err) | ||
return cudo.SearchApi(c) | ||
|
||
|
||
def user(): | ||
c, err = client() | ||
if err: | ||
raise Exception(err) | ||
return cudo.UserApi(c) | ||
|
||
|
||
def virtualmachines(): | ||
c, err = client() | ||
if err: | ||
raise Exception(err) | ||
return cudo.VirtualMachinesApi(c) |
This file was deleted.
Oops, something went wrong.
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.1.1" | ||
version = "0.1.2" | ||
authors = [ | ||
{ name = "Cudo Ventures", email = "[email protected]" }, | ||
] | ||
|