Skip to content

Commit

Permalink
include update in request protos
Browse files Browse the repository at this point in the history
  • Loading branch information
viniciusdc committed Jan 12, 2024
1 parent f5f5e14 commit c89b948
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 61 deletions.
43 changes: 30 additions & 13 deletions protos/workflow.proto
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,20 @@ message DagTemplate {
}

message ScriptTemplate {
optional string source = 1;
optional string image = 1;
repeated string command = 2;
map<string, string> resources = 3;
optional string source = 4;
}

message Template {
optional string name = 1;
optional string container = 2;
optional Inputs inputs = 3;
optional Outputs outputs = 4;
optional DagTemplate dag = 5;
optional ScriptTemplate script = 6;
map<string, string> metadata = 3;
optional Inputs inputs = 4;
optional Outputs outputs = 5;
optional DagTemplate dag = 6;
optional ScriptTemplate script = 7;
}

message Spec {
Expand All @@ -80,16 +84,28 @@ message Spec {
repeated Template templates = 3;
}

message Metadata {
optional string generateName = 1;
optional string namespace = 2;
map<string, string> labels = 3;
}

message Workflow {
Metadata metadata = 1;
Spec spec = 2;
}

/**
* Argo workflow CRUD resources
*/

message WorkflowCreationRequest {
optional string name = 1;
optional string namespace = 2;
optional string workflowTemplate = 4;
optional string workflowSpec = 5;
optional string description = 2;
optional string user_uid = 3;
optional string namespace = 4;
optional bool serverDryRun = 5;
optional Workflow workflow = 6;
}

message WorkflowCreationResponse {
Expand All @@ -100,8 +116,7 @@ message WorkflowCreationResponse {
message WorkflowUpdateRequest {
optional string name = 1;
optional string namespace = 2;
optional string workflowTemplate = 4;
optional string workflowSpec = 5;
optional Workflow workflow = 3;
}

message WorkflowUpdateResponse {
Expand All @@ -110,7 +125,7 @@ message WorkflowUpdateResponse {
}

message WorkflowDeleteRequest {
optional string name = 1;
optional string workflow_name = 1;
optional string namespace = 2;
}

Expand All @@ -120,7 +135,7 @@ message WorkflowDeleteResponse {
}

message WorkflowGetRequest {
optional string name = 1;
optional string workflow_name = 1;
optional string namespace = 2;
}

Expand All @@ -129,7 +144,9 @@ message WorkflowGetResponse {
optional string message = 2;
}

message WorkflowListRequest {}
message WorkflowListRequest {
optional string namespace = 1;
}

message WorkflowListResponse {
repeated WorkflowGetResponse workflows = 1;
Expand Down
52 changes: 41 additions & 11 deletions python/naas_models/pydantic/workflow_p2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,12 @@ class DagTemplate(BaseModel):

class ScriptTemplate(BaseModel):

_one_of_dict = {"ScriptTemplate._source": {"fields": {"source"}}}
_one_of_dict = {"ScriptTemplate._image": {"fields": {"image"}}, "ScriptTemplate._source": {"fields": {"source"}}}
_check_one_of = root_validator(pre=True, allow_reuse=True)(check_one_of)

image: str = FieldInfo(default="")
command: typing.List[str] = FieldInfo(default_factory=list)
resources: typing.Dict[str, str] = FieldInfo(default_factory=dict)
source: str = FieldInfo(default="")


Expand All @@ -122,6 +125,7 @@ class Template(BaseModel):

name: str = FieldInfo(default="")
container: str = FieldInfo(default="")
metadata: typing.Dict[str, str] = FieldInfo(default_factory=dict)
inputs: Inputs = FieldInfo()
outputs: Outputs = FieldInfo()
dag: DagTemplate = FieldInfo()
Expand All @@ -142,15 +146,37 @@ class Spec(BaseModel):



class Metadata(BaseModel):

_one_of_dict = {"Metadata._generateName": {"fields": {"generateName"}}, "Metadata._namespace": {"fields": {"namespace"}}}
_check_one_of = root_validator(pre=True, allow_reuse=True)(check_one_of)

generateName: str = FieldInfo(default="")
namespace: str = FieldInfo(default="")
labels: typing.Dict[str, str] = FieldInfo(default_factory=dict)




class Workflow(BaseModel):

metadata: Metadata = FieldInfo()
spec: Spec = FieldInfo()




class WorkflowCreationRequest(BaseModel):

_one_of_dict = {"WorkflowCreationRequest._name": {"fields": {"name"}}, "WorkflowCreationRequest._namespace": {"fields": {"namespace"}}, "WorkflowCreationRequest._workflowSpec": {"fields": {"workflowSpec"}}, "WorkflowCreationRequest._workflowTemplate": {"fields": {"workflowTemplate"}}}
_one_of_dict = {"WorkflowCreationRequest._description": {"fields": {"description"}}, "WorkflowCreationRequest._name": {"fields": {"name"}}, "WorkflowCreationRequest._namespace": {"fields": {"namespace"}}, "WorkflowCreationRequest._serverDryRun": {"fields": {"serverDryRun"}}, "WorkflowCreationRequest._user_uid": {"fields": {"user_uid"}}, "WorkflowCreationRequest._workflow": {"fields": {"workflow"}}}
_check_one_of = root_validator(pre=True, allow_reuse=True)(check_one_of)

name: str = FieldInfo(default="")
description: str = FieldInfo(default="")
user_uid: str = FieldInfo(default="")
namespace: str = FieldInfo(default="")
workflowTemplate: str = FieldInfo(default="")
workflowSpec: str = FieldInfo(default="")
serverDryRun: bool = FieldInfo(default=False)
workflow: Workflow = FieldInfo()



Expand All @@ -168,13 +194,12 @@ class WorkflowCreationResponse(BaseModel):

class WorkflowUpdateRequest(BaseModel):

_one_of_dict = {"WorkflowUpdateRequest._name": {"fields": {"name"}}, "WorkflowUpdateRequest._namespace": {"fields": {"namespace"}}, "WorkflowUpdateRequest._workflowSpec": {"fields": {"workflowSpec"}}, "WorkflowUpdateRequest._workflowTemplate": {"fields": {"workflowTemplate"}}}
_one_of_dict = {"WorkflowUpdateRequest._name": {"fields": {"name"}}, "WorkflowUpdateRequest._namespace": {"fields": {"namespace"}}, "WorkflowUpdateRequest._workflow": {"fields": {"workflow"}}}
_check_one_of = root_validator(pre=True, allow_reuse=True)(check_one_of)

name: str = FieldInfo(default="")
namespace: str = FieldInfo(default="")
workflowTemplate: str = FieldInfo(default="")
workflowSpec: str = FieldInfo(default="")
workflow: Workflow = FieldInfo()



Expand All @@ -192,10 +217,10 @@ class WorkflowUpdateResponse(BaseModel):

class WorkflowDeleteRequest(BaseModel):

_one_of_dict = {"WorkflowDeleteRequest._name": {"fields": {"name"}}, "WorkflowDeleteRequest._namespace": {"fields": {"namespace"}}}
_one_of_dict = {"WorkflowDeleteRequest._namespace": {"fields": {"namespace"}}, "WorkflowDeleteRequest._workflow_name": {"fields": {"workflow_name"}}}
_check_one_of = root_validator(pre=True, allow_reuse=True)(check_one_of)

name: str = FieldInfo(default="")
workflow_name: str = FieldInfo(default="")
namespace: str = FieldInfo(default="")


Expand All @@ -214,10 +239,10 @@ class WorkflowDeleteResponse(BaseModel):

class WorkflowGetRequest(BaseModel):

_one_of_dict = {"WorkflowGetRequest._name": {"fields": {"name"}}, "WorkflowGetRequest._namespace": {"fields": {"namespace"}}}
_one_of_dict = {"WorkflowGetRequest._namespace": {"fields": {"namespace"}}, "WorkflowGetRequest._workflow_name": {"fields": {"workflow_name"}}}
_check_one_of = root_validator(pre=True, allow_reuse=True)(check_one_of)

name: str = FieldInfo(default="")
workflow_name: str = FieldInfo(default="")
namespace: str = FieldInfo(default="")


Expand All @@ -236,6 +261,11 @@ class WorkflowGetResponse(BaseModel):

class WorkflowListRequest(BaseModel):

_one_of_dict = {"WorkflowListRequest._namespace": {"fields": {"namespace"}}}
_check_one_of = root_validator(pre=True, allow_reuse=True)(check_one_of)

namespace: str = FieldInfo(default="")




Expand Down
Loading

0 comments on commit c89b948

Please sign in to comment.