|
17 | 17 |
|
18 | 18 | # Create a new 1V100.6V instance |
19 | 19 | instance = datacrunch.instances.create(instance_type='1V100.6V', |
20 | | - image='fastai', |
| 20 | + image='ubuntu-24.04-cuda-12.8-open-docker', |
21 | 21 | ssh_key_ids=ssh_keys_ids, |
22 | 22 | hostname='example', |
23 | 23 | description='example instance') |
|
27 | 27 | # Try to shutdown instance right away, |
28 | 28 | # encounter an error (because it's still provisioning) |
29 | 29 | try: |
30 | | - datacrunch.instances.action(instance.id, datacrunch.constants.instance_actions.SHUTDOWN) |
| 30 | + datacrunch.instances.action( |
| 31 | + instance.id, datacrunch.constants.instance_actions.SHUTDOWN) |
31 | 32 | except APIException as exception: |
32 | 33 | print(exception) # we were too eager... |
33 | 34 |
|
34 | 35 | # Wait until instance is running (check every 30sec), only then shut it down |
35 | | -while(instance.status != datacrunch.constants.instance_status.RUNNING): |
| 36 | +while (instance.status != datacrunch.constants.instance_status.RUNNING): |
36 | 37 | time.sleep(30) |
37 | 38 | instance = datacrunch.instances.get_by_id(instance.id) |
38 | 39 |
|
39 | 40 | # Shutdown! |
40 | 41 | try: |
41 | | - datacrunch.instances.action(instance.id, datacrunch.constants.instance_actions.SHUTDOWN) |
| 42 | + datacrunch.instances.action( |
| 43 | + instance.id, datacrunch.constants.instance_actions.SHUTDOWN) |
42 | 44 | except APIException as exception: |
43 | 45 | print(exception) # no exception this time |
44 | 46 |
|
45 | 47 | # Wait until instance is offline (check every 30sec), only then hibernate |
46 | | -while(instance.status != datacrunch.constants.instance_status.OFFLINE): |
| 48 | +while (instance.status != datacrunch.constants.instance_status.OFFLINE): |
47 | 49 | time.sleep(30) |
48 | 50 | instance = datacrunch.instances.get_by_id(instance.id) |
49 | 51 |
|
50 | 52 | # Hibernate the instance |
51 | 53 | try: |
52 | | - datacrunch.instances.action(instance.id, datacrunch.constants.instance_actions.HIBERNATE) |
| 54 | + datacrunch.instances.action( |
| 55 | + instance.id, datacrunch.constants.instance_actions.HIBERNATE) |
53 | 56 | except APIException as exception: |
54 | 57 | print(exception) |
0 commit comments