Skip to content

Commit

Permalink
example fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JungleCatSW committed Dec 30, 2024
1 parent b6ef16d commit 707eb49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 43 deletions.
47 changes: 6 additions & 41 deletions examples/machine-types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,9 @@
from cudo_compute.rest import ApiException
import json


def machine_types(gpu_model, mem_gib, vcpu_count, gpu_count):
try:
api = cudo_api.virtual_machines()
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['host_configs']
except ApiException as e:
raise e


def gpu_types(gpu_count):
try:
api = cudo_api.virtual_machines()
types = api.list_vm_machine_types(1, 1, gpu=gpu_count, )
gpu_list = []
for gpu in types.to_dict()['gpu_models']:
gpu_list.append(gpu['name'])
return gpu_list
except ApiException as e:
raise e


print('Gpu types')
print(json.dumps(gpu_types(1), indent=2))

print('Machine types with GPU')
mts = machine_types("", 1, 1, 1)
mt_list = []
for mt in mts:
mt_list.append(
{'machine_type': mt['machine_type'], 'gpu_model': mt['gpu_model'], 'data_center_id': mt['data_center_id']})
print(json.dumps(mt_list, indent=2))

print('Machine types without GPU')
mts = machine_types("", 1, 1, 0)
mt_list = []
for mt in mts:
mt_list.append(
{'machine_type': mt['machine_type'], 'data_center_id': mt['data_center_id']})
print(json.dumps(mt_list, indent=2))
try:
api = cudo_api.virtual_machines()
all_types = api.list_vm_machine_types2()
print(json.dumps(all_types.to_dict(), indent=2))
except ApiException as e:
print(e)
3 changes: 2 additions & 1 deletion helpers/cudo_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def stop_workers(self):
self.workers_active = False
self.shutdown_event.set()

self.executor.shutdown(wait=False)
if self.executor:
self.executor.shutdown(wait=False)

except Exception as e:
print(f"Error shutting down: {e}")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "cudo-compute"
version = "0.3.2"
version = "0.3.3"
authors = [
{ name = "Cudo Ventures", email = "[email protected]" },
]
Expand Down

0 comments on commit 707eb49

Please sign in to comment.