-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #188 from runpod/1.3.1-changelog
1.3.1 changelog
- Loading branch information
Showing
21 changed files
with
567 additions
and
22 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,30 @@ | ||
""" Example of creating an endpoint with the Runpod API. """ | ||
|
||
import runpod | ||
|
||
# Set your global API key with `runpod config` or uncomment the line below: | ||
# runpod.api_key = "YOUR_RUNPOD_API_KEY" | ||
|
||
try: | ||
|
||
new_template = runpod.create_template( | ||
name="test", | ||
image_name="runpod/base:0.1.0", | ||
is_serverless=True | ||
) | ||
|
||
print(new_template) | ||
|
||
new_endpoint = runpod.create_endpoint( | ||
name="test", | ||
template_id=new_template["id"], | ||
gpu_ids="AMPERE_16", | ||
workers_min=0, | ||
workers_max=1 | ||
) | ||
|
||
print(new_endpoint) | ||
|
||
except runpod.error.QueryError as err: | ||
print(err) | ||
print(err.query) |
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,19 @@ | ||
""" Example of creating a template with the Runpod API. """ | ||
|
||
import runpod | ||
|
||
# Set your global API key with `runpod config` or uncomment the line below: | ||
# runpod.api_key = "YOUR_RUNPOD_API_KEY" | ||
|
||
try: | ||
|
||
new_template = runpod.create_template( | ||
name="test", | ||
image_name="runpod/base:0.1.0" | ||
) | ||
|
||
print(new_template) | ||
|
||
except runpod.error.QueryError as err: | ||
print(err) | ||
print(err.query) |
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
""" RunPod | API Wrapper | Mutations | Endpoints """ | ||
|
||
# pylint: disable=too-many-arguments | ||
|
||
def generate_endpoint_mutation( | ||
name:str, template_id:str, gpu_ids:str="AMPERE_16", | ||
network_volume_id:str=None, locations:str=None, | ||
idle_timeout:int=5, scaler_type:str="QUEUE_DELAY", scaler_value:int=4, | ||
workers_min:int=0, workers_max:int=3 | ||
): | ||
""" Generate a string for a GraphQL mutation to create a new endpoint. """ | ||
input_fields = [] | ||
|
||
# ------------------------------ Required Fields ----------------------------- # | ||
input_fields.append(f'name: "{name}"') | ||
input_fields.append(f'templateId: "{template_id}"') | ||
input_fields.append(f'gpuIds: "{gpu_ids}"') | ||
|
||
# ------------------------------ Optional Fields ----------------------------- # | ||
if network_volume_id is not None: | ||
input_fields.append(f'networkVolumeId: "{network_volume_id}"') | ||
else: | ||
input_fields.append('networkVolumeId: ""') | ||
|
||
if locations is not None: | ||
input_fields.append(f'locations: "{locations}"') | ||
else: | ||
input_fields.append('locations: ""') | ||
|
||
input_fields.append(f'idleTimeout: {idle_timeout}') | ||
input_fields.append(f'scalerType: "{scaler_type}"') | ||
input_fields.append(f'scalerValue: {scaler_value}') | ||
input_fields.append(f'workersMin: {workers_min}') | ||
input_fields.append(f'workersMax: {workers_max}') | ||
|
||
# Format the input fields into a string | ||
input_fields_string = ", ".join(input_fields) | ||
|
||
return f""" | ||
mutation {{ | ||
saveEndpoint( | ||
input: {{ | ||
{input_fields_string} | ||
}} | ||
) {{ | ||
id | ||
name | ||
templateId | ||
gpuIds | ||
networkVolumeId | ||
locations | ||
idleTimeout | ||
scalerType | ||
scalerValue | ||
workersMin | ||
workersMax | ||
}} | ||
}} | ||
""" |
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,83 @@ | ||
""" RunPod | API Wrapper | Mutations | Templates """ | ||
|
||
# pylint: disable=too-many-arguments | ||
|
||
def generate_pod_template( | ||
name:str, image_name:str, docker_start_cmd:str=None, | ||
container_disk_in_gb:int=10, volume_in_gb:int=None, volume_mount_path:str=None, | ||
ports:str=None, env:dict=None, is_serverless:bool=False | ||
): | ||
""" Generate a string for a GraphQL mutation to create a new pod template. """ | ||
input_fields = [] | ||
|
||
# ------------------------------ Required Fields ----------------------------- # | ||
input_fields.append(f'name: "{name}"') | ||
input_fields.append(f'imageName: "{image_name}"') | ||
|
||
# ------------------------------ Optional Fields ----------------------------- # | ||
if docker_start_cmd is not None: | ||
docker_start_cmd = docker_start_cmd.replace('"', '\\"') | ||
input_fields.append(f'dockerArgs: "{docker_start_cmd}"') | ||
else: | ||
input_fields.append('dockerArgs: ""') | ||
|
||
input_fields.append(f'containerDiskInGb: {container_disk_in_gb}') | ||
|
||
if volume_in_gb is not None: | ||
input_fields.append(f'volumeInGb: {volume_in_gb}') | ||
else: | ||
input_fields.append('volumeInGb: 0') | ||
|
||
if volume_mount_path is not None: | ||
input_fields.append(f'volumeMountPath: "{volume_mount_path}"') | ||
|
||
if ports is not None: | ||
ports = ports.replace(" ", "") | ||
input_fields.append(f'ports: "{ports}"') | ||
else: | ||
input_fields.append('ports: ""') | ||
|
||
if env is not None: | ||
env_string = ", ".join( | ||
[f'{{ key: "{key}", value: "{value}" }}' for key, value in env.items()]) | ||
input_fields.append(f"env: [{env_string}]") | ||
else: | ||
input_fields.append('env: []') | ||
|
||
|
||
if is_serverless: | ||
input_fields.append('isServerless: true') | ||
else: | ||
input_fields.append('isServerless: false') | ||
|
||
# ------------------------------ Enforced Fields ----------------------------- # | ||
input_fields.append('startSsh: true') | ||
input_fields.append('isPublic: false') | ||
input_fields.append('readme: ""') | ||
|
||
# Format the input fields into a string | ||
input_fields_string = ", ".join(input_fields) | ||
|
||
return f""" | ||
mutation {{ | ||
saveTemplate( | ||
input: {{ | ||
{input_fields_string} | ||
}} | ||
) {{ | ||
id | ||
name | ||
imageName | ||
dockerArgs | ||
containerDiskInGb | ||
volumeInGb | ||
volumeMountPath | ||
ports | ||
env {{ | ||
key | ||
value | ||
}} | ||
isServerless | ||
}} | ||
}} | ||
""" |
Oops, something went wrong.