Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
8de0ce8f
Commit
8de0ce8f
authored
4 years ago
by
Nathan Hertz
Browse files
Options
Downloads
Patches
Plain Diff
Updated CapabilityStep class to support workflow arguments; updated
null.cap with arguments
parent
dc5a49ea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
services/capability/test/null.cap
+1
-1
1 addition, 1 deletion
services/capability/test/null.cap
shared/workspaces/src/workspaces/helpers.py
+38
-21
38 additions, 21 deletions
shared/workspaces/src/workspaces/helpers.py
with
39 additions
and
22 deletions
services/capability/test/null.cap
+
1
−
1
View file @
8de0ce8f
0 null 2
prepare-and-run-workflow null
prepare-and-run-workflow null
-g
await-parameter qa-status
\ No newline at end of file
This diff is collapsed.
Click to expand it.
shared/workspaces/src/workspaces/helpers.py
+
38
−
21
View file @
8de0ce8f
...
...
@@ -3,8 +3,12 @@ from __future__ import annotations
from
enum
import
Enum
,
auto
from
typing
import
Optional
,
List
,
Iterator
from
.capability_interfaces
import
ParameterIF
,
CapabilityStepIF
,
CapabilitySequenceIF
,
\
CapabilityRequestIF
from
.capability_interfaces
import
(
ParameterIF
,
CapabilityStepIF
,
CapabilitySequenceIF
,
CapabilityRequestIF
,
)
from
.product_interfaces
import
FutureProductIF
...
...
@@ -13,36 +17,44 @@ class CapabilityStep(CapabilityStepIF):
Class that represents a step in a capability sequence. A step is of a certain type and
certain step types can have a value
"""
def
__init__
(
self
,
step_type
:
CapabilityStepType
,
step_value
:
Optional
[
str
]):
def
__init__
(
self
,
step_type
:
CapabilityStepType
,
step_value
:
Optional
[
str
],
step_args
:
Optional
[
str
],
):
self
.
step_type
=
step_type
self
.
step_value
=
step_value
self
.
step_args
=
step_args
@classmethod
def
from_str
(
cls
,
step_string
:
str
):
"""
Create CapabilityStep from string containing space-separated
step type and step value
Create CapabilityStep from string containing space-separated
type, value, and args
:param step_string: String of capability step, e.g.
"
PrepareAndRunWorkflow null
"
:return: CapabilityStep of given string
"""
step_list
=
step_string
.
split
(
'
'
)
step_list
=
step_string
.
split
(
"
"
)
step_type
=
CapabilityStepType
.
from_string
(
step_list
[
0
])
if
step_list
[
1
]:
step_value
=
step_list
[
1
]
else
:
step_value
=
None
return
cls
(
step_type
,
step_value
)
step_value
=
step_list
[
1
]
if
step_list
[
1
]
else
None
step_args
=
step_list
[
2
]
if
step_list
[
2
]
else
None
return
cls
(
step_type
,
step_value
,
step_args
)
def
__str__
(
self
):
string
=
f
"
{
self
.
step_type
.
name
}
"
if
self
.
step_value
:
return
f
'
{
self
.
step_type
.
name
}
{
self
.
step_value
}
'
else
:
return
f
'
{
self
.
step_type
.
name
}
'
string
+=
f
"
{
self
.
step_value
}
"
elif
self
.
step_args
:
string
+=
f
"
{
self
.
step_args
}
"
return
string
class
CapabilitySequence
(
CapabilitySequenceIF
):
"""
Class that represents a capability sequence with a list of steps
"""
def
__init__
(
self
,
steps
:
List
[
CapabilityStep
]):
self
.
steps
=
steps
...
...
@@ -54,7 +66,7 @@ class CapabilitySequence(CapabilitySequenceIF):
:return: CapabilitySequence of given steps
"""
steps
=
[]
for
step
in
sequence_str
.
split
(
'
,
'
):
for
step
in
sequence_str
.
split
(
"
,
"
):
steps
.
append
(
CapabilityStep
.
from_str
(
step
))
return
cls
(
steps
)
...
...
@@ -82,7 +94,7 @@ class CapabilitySequence(CapabilitySequenceIF):
:return: String representation
"""
str_steps
=
[
str
(
step
)
for
step
in
self
]
return
'
,
'
.
join
(
str_steps
)
return
"
,
"
.
join
(
str_steps
)
class
Parameter
(
ParameterIF
):
...
...
@@ -97,6 +109,7 @@ class CapabilityStepType(Enum):
"""
Enum that specifies the types of CapabilitySteps that are possible
"""
PrepareAndRunWorkflow
=
0
AwaitQA
=
1
AwaitWorkflow
=
2
...
...
@@ -108,12 +121,12 @@ class CapabilityStepType(Enum):
def
from_string
(
cls
,
string
:
str
)
->
CapabilityStepType
:
print
(
string
)
strings
=
{
'
prepare-and-run-workflow
'
:
cls
.
PrepareAndRunWorkflow
,
'
await-qa
'
:
cls
.
AwaitQA
,
'
await-workflow
'
:
cls
.
AwaitWorkflow
,
'
await-product
'
:
cls
.
AwaitProduct
,
'
await-parameter
'
:
cls
.
AwaitParameter
,
'
await-large-alloc-approval
'
:
cls
.
AwaitLargeAllocApproval
"
prepare-and-run-workflow
"
:
cls
.
PrepareAndRunWorkflow
,
"
await-qa
"
:
cls
.
AwaitQA
,
"
await-workflow
"
:
cls
.
AwaitWorkflow
,
"
await-product
"
:
cls
.
AwaitProduct
,
"
await-parameter
"
:
cls
.
AwaitParameter
,
"
await-large-alloc-approval
"
:
cls
.
AwaitLargeAllocApproval
,
}
return
strings
[
string
]
...
...
@@ -122,6 +135,7 @@ class CapabilityEventType(Enum):
"""
Enum that specifies the type of CapabilityEvents possible to send
"""
WorkflowComplete
=
0
QaApproval
=
1
QaDenial
=
1
...
...
@@ -136,6 +150,7 @@ class RequestState(Enum):
"""
Enum that specifies the states that a capability request can be in
"""
Complete
=
0
Executing
=
1
Ready
=
2
...
...
@@ -146,6 +161,7 @@ class ExecutionState(Enum):
"""
Enum that specifies the states that a capability execution can find itself in
"""
Complete
=
0
ExecutingStep
=
1
Ready
=
2
...
...
@@ -157,6 +173,7 @@ class ExecutionPriority(Enum):
"""
Enum that specifies the priority of a particular capability execution
"""
High
=
25
Default
=
50
Low
=
100
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment