Skip to content

Commit

Permalink
Merge pull request #104 from trickest/fix/workflow-version-data
Browse files Browse the repository at this point in the history
Refactor workflow version data struct type
  • Loading branch information
mhmdiaa authored Dec 12, 2023
2 parents bc480a1 + 4a7f4ab commit 8e90ba3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 44 deletions.
14 changes: 2 additions & 12 deletions cmd/execute/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -833,12 +833,7 @@ func readWorkflowYAMLandCreateVersion(fileName string, workflowName string, obje
version := &types.WorkflowVersionDetailed{
WorkflowInfo: workflowID,
Name: nil,
Data: struct {
Nodes map[string]*types.Node `json:"nodes"`
Connections []types.Connection `json:"connections"`
PrimitiveNodes map[string]*types.PrimitiveNode `json:"primitiveNodes"`
Annotations map[string]*types.Annotation `json:"annotations"`
}{
Data: types.WorkflowVersionData{
Nodes: nodes,
Connections: connections,
PrimitiveNodes: primitiveNodes,
Expand Down Expand Up @@ -962,12 +957,7 @@ func createToolWorkflow(wfName string, space *types.SpaceDetailed, project *type
newVersion := &types.WorkflowVersionDetailed{
WorkflowInfo: workflowID,
Name: nil,
Data: struct {
Nodes map[string]*types.Node `json:"nodes"`
Connections []types.Connection `json:"connections"`
PrimitiveNodes map[string]*types.PrimitiveNode `json:"primitiveNodes"`
Annotations map[string]*types.Annotation `json:"annotations"`
}{
Data: types.WorkflowVersionData{
Nodes: map[string]*types.Node{
node.Name: node,
},
Expand Down
60 changes: 28 additions & 32 deletions types/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,34 @@ type SubJobOutput struct {
SignedURL string `json:"signed_url,omitempty"`
}

type WorkflowVersionData struct {
Nodes map[string]*Node `json:"nodes"`
Connections []Connection `json:"connections"`
PrimitiveNodes map[string]*PrimitiveNode `json:"primitiveNodes"`
Annotations map[string]*Annotation `json:"annotation,omitempty"`
}

type WorkflowVersionDetailed struct {
ID uuid.UUID `json:"id"`
Version int `json:"version"`
WorkflowInfo uuid.UUID `json:"workflow_info"`
Name *string `json:"name,omitempty"`
Description string `json:"description"`
Public bool `json:"public"`
CreatedDate time.Time `json:"created_date"`
RunCount int `json:"run_count"`
MaxMachines Machines `json:"max_machines"`
Snapshot bool `json:"snapshot"`
Data struct {
Nodes map[string]*Node `json:"nodes"`
Connections []Connection `json:"connections"`
PrimitiveNodes map[string]*PrimitiveNode `json:"primitiveNodes"`
Annotations map[string]*Annotation `json:"annotations"`
} `json:"data"`
ID uuid.UUID `json:"id"`
Version int `json:"version"`
WorkflowInfo uuid.UUID `json:"workflow_info"`
Name *string `json:"name,omitempty"`
Description string `json:"description"`
Public bool `json:"public"`
CreatedDate time.Time `json:"created_date"`
RunCount int `json:"run_count"`
MaxMachines Machines `json:"max_machines"`
Snapshot bool `json:"snapshot"`
Data WorkflowVersionData `json:"data"`
}
type WorkflowVersionStripped struct {
ID uuid.UUID `json:"id"`
WorkflowInfo uuid.UUID `json:"workflow_info"`
Name *string `json:"name,omitempty"`
Description string `json:"description"`
MaxMachines Machines `json:"max_machines"`
Snapshot bool `json:"snapshot"`
Data WorkflowVersionData `json:"data"`
}

type Annotation struct {
Expand All @@ -65,21 +76,6 @@ type Annotation struct {
} `json:"coordinates"`
}

type WorkflowVersionStripped struct {
ID uuid.UUID `json:"id"`
WorkflowInfo uuid.UUID `json:"workflow_info"`
Name *string `json:"name,omitempty"`
Description string `json:"description"`
MaxMachines Machines `json:"max_machines"`
Snapshot bool `json:"snapshot"`
Data struct {
Nodes map[string]*Node `json:"nodes"`
Connections []Connection `json:"connections"`
PrimitiveNodes map[string]*PrimitiveNode `json:"primitiveNodes"`
Annotations map[string]*Annotation `json:"annotations"`
} `json:"data"`
}

type Connection struct {
Source struct {
ID string `json:"id"`
Expand Down Expand Up @@ -152,5 +148,5 @@ type NodeInput struct {
Description *string `json:"description,omitempty"`
WorkerConnected *bool `json:"workerConnected,omitempty"`
Multi *bool `json:"multi,omitempty"`
Visible *bool `json:"visible"`
Visible *bool `json:"visible,omitempty"`
}

0 comments on commit 8e90ba3

Please sign in to comment.