Skip to content

Commit

Permalink
chore: Convert tabs to spaces and update CODEOWNERS (#373)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger Lam authored Oct 5, 2021
1 parent 30fc256 commit 2dca4d9
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 258 deletions.
4 changes: 3 additions & 1 deletion CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# These owners will be the default owners for everything in
# the repo.
* @BartoszCki @mkulaczkowski @kossak @dandruszak

**/*deployment*.py @Paperspace/gradient-deployments
**/*model*.py @Paperspace/gradient-deployments
372 changes: 186 additions & 186 deletions gradient/api_sdk/repositories/gradient_deployments.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,203 +3,203 @@


def create_deployment(name, project_id, spec, cluster_id=None):
client = graphql_client()
query = gql(
"""
mutation createDeployment($input: CreateDeploymentInput!) {
createDeployment(input: $input) {
deployment {
id
}
}
}
"""
)
params = {
"input": {
"name": name,
"clusterId": cluster_id,
"projectId": project_id,
"spec": spec,
}
}
return client.execute(query, variable_values=params)['createDeployment']['deployment']
client = graphql_client()
query = gql(
"""
mutation createDeployment($input: CreateDeploymentInput!) {
createDeployment(input: $input) {
deployment {
id
}
}
}
"""
)
params = {
"input": {
"name": name,
"clusterId": cluster_id,
"projectId": project_id,
"spec": spec,
}
}
return client.execute(query, variable_values=params)['createDeployment']['deployment']


def update_deployment(id, name=None, project_id=None, spec=None, cluster_id=None):
client = graphql_client()
query = gql(
"""
mutation updateDeployment($input: UpdateDeploymentInput!) {
updateDeployment(input: $input) {
deployment {
id
}
}
}
"""
)
client = graphql_client()
query = gql(
"""
mutation updateDeployment($input: UpdateDeploymentInput!) {
updateDeployment(input: $input) {
deployment {
id
}
}
}
"""
)

input = {
"id": id,
}
if name is not None:
input["name"] = name
if project_id is not None:
input["projectId"] = project_id
if cluster_id is not None:
input["clusterId"] = cluster_id
if spec is not None:
input["spec"] = spec
input = {
"id": id,
}
if name is not None:
input["name"] = name
if project_id is not None:
input["projectId"] = project_id
if cluster_id is not None:
input["clusterId"] = cluster_id
if spec is not None:
input["spec"] = spec

params = {
"input": input
}
return client.execute(query, variable_values=params)['updateDeployment']['deployment']
params = {
"input": input
}
return client.execute(query, variable_values=params)['updateDeployment']['deployment']


def get_deployment(id, first=100):
client = graphql_client()
query = gql(
"""
query getDeployment($id: UUID!, $first: Int!) {
deployment(id: $id) {
id
name
deploymentSpecs(first: $first) {
nodes {
id
data {
image
port
resources {
instanceType
replicas
}
}
endpointUrl
actor {
avatarUrl
fullName
}
cluster {
id
}
data {
command
env {
name
value
}
image
models {
id
path
}
port
resources {
replicas
}
}
deploymentRuns(first: $first) {
nodes {
id
availableReplicas
readyReplicas
replicas
deploymentRunInstances(first: $first) {
nodes {
id
phase
dtStarted
dtFinished
}
}
}
}
}
}
}
}
"""
)
params = {
"id": id,
"first": first,
}
return client.execute(query, variable_values=params)
client = graphql_client()
query = gql(
"""
query getDeployment($id: UUID!, $first: Int!) {
deployment(id: $id) {
id
name
deploymentSpecs(first: $first) {
nodes {
id
data {
image
port
resources {
instanceType
replicas
}
}
endpointUrl
actor {
avatarUrl
fullName
}
cluster {
id
}
data {
command
env {
name
value
}
image
models {
id
path
}
port
resources {
replicas
}
}
deploymentRuns(first: $first) {
nodes {
id
availableReplicas
readyReplicas
replicas
deploymentRunInstances(first: $first) {
nodes {
id
phase
dtStarted
dtFinished
}
}
}
}
}
}
}
}
"""
)
params = {
"id": id,
"first": first,
}
return client.execute(query, variable_values=params)


def list_deployments(first=100):
client = graphql_client()
query = gql(
"""
query getDeployments($first: Int!) {
deployments(first: $first) {
nodes {
id
name
deploymentSpecs(first: $first) {
nodes {
id
data {
image
port
resources {
instanceType
replicas
}
}
endpointUrl
actor {
avatarUrl
fullName
}
deploymentRuns(first: $first) {
nodes {
id
availableReplicas
readyReplicas
replicas
deploymentRunInstances(first: $first) {
nodes {
id
phase
dtStarted
dtFinished
}
}
}
}
}
}
}
}
}
"""
)
params = {
"first": first,
}
return client.execute(query, variable_values=params)['deployments']['nodes']
client = graphql_client()
query = gql(
"""
query getDeployments($first: Int!) {
deployments(first: $first) {
nodes {
id
name
deploymentSpecs(first: $first) {
nodes {
id
data {
image
port
resources {
instanceType
replicas
}
}
endpointUrl
actor {
avatarUrl
fullName
}
deploymentRuns(first: $first) {
nodes {
id
availableReplicas
readyReplicas
replicas
deploymentRunInstances(first: $first) {
nodes {
id
phase
dtStarted
dtFinished
}
}
}
}
}
}
}
}
}
"""
)
params = {
"first": first,
}
return client.execute(query, variable_values=params)['deployments']['nodes']


def delete_deployment(id):
client = graphql_client()
query = gql(
"""
mutation deleteDeployment($input: DeleteDeploymentInput!) {
deleteDeployment(input: $input) {
deployment {
id
}
}
}
"""
)
params = {
"input": {
"id": id,
}
}
return client.execute(query, variable_values=params)['deleteDeployment']
client = graphql_client()
query = gql(
"""
mutation deleteDeployment($input: DeleteDeploymentInput!) {
deleteDeployment(input: $input) {
deployment {
id
}
}
}
"""
)
params = {
"input": {
"id": id,
}
}
return client.execute(query, variable_values=params)['deleteDeployment']
Loading

0 comments on commit 2dca4d9

Please sign in to comment.