Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hypha
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
Container 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ots
hypha
Commits
a25d81d8
Commit
a25d81d8
authored
7 years ago
by
Todd Dembrey
Browse files
Options
Downloads
Patches
Plain Diff
Remove knowledge about how phase names are built from the workflow class
parent
9a31512f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
opentech/apply/workflow.py
+18
-7
18 additions, 7 deletions
opentech/apply/workflow.py
with
18 additions
and
7 deletions
opentech/apply/workflow.py
+
18
−
7
View file @
a25d81d8
...
...
@@ -12,6 +12,16 @@ Workflow -> Stage -> Phase -> Action
"""
def
phase_name
(
stage
:
'
Stage
'
,
phase
:
Union
[
'
Phase
'
,
str
],
occurance
:
int
)
->
str
:
# Build the identifiable name for a phase
if
not
isinstance
(
phase
,
str
):
phase_name
=
phase
.
_internal
else
:
phase_name
=
phase
return
'
__
'
.
join
([
stage
.
name
,
phase_name
,
str
(
occurance
)])
class
Workflow
:
"""
A Workflow is a collection of Stages an application goes through. When a Stage is complete,
...
...
@@ -33,10 +43,11 @@ class Workflow:
if
not
current_phase
:
return
self
.
first
()
stage_name
,
phase_name
,
occurance
=
current_phase
.
split
(
'
__
'
)
for
stage
in
self
.
stages
:
if
stage
.
name
==
stage_name
:
return
stage
.
current
(
phase_name
,
occurance
)
phase
=
stage
.
get_phase
(
current_phase
)
if
phase
:
return
phase
return
None
def
first
(
self
)
->
'
Phase
'
:
...
...
@@ -112,9 +123,9 @@ class Stage:
def
__str__
(
self
)
->
str
:
return
self
.
name
def
current
(
self
,
phase_name
:
str
,
occurance
:
str
)
->
'
Phase
'
:
def
get_phase
(
self
,
phase_name
:
str
)
->
'
Phase
'
:
for
phase
in
self
.
phases
:
if
phas
e
.
_internal
==
phase_name
and
int
(
occuranc
e
)
==
phase
.
occuranc
e
:
if
str
(
phase
)
==
phase
_nam
e
:
return
phase
return
None
...
...
@@ -166,7 +177,7 @@ class Phase:
return
list
(
self
.
_actions
.
keys
())
def
__str__
(
self
)
->
str
:
return
'
__
'
.
join
([
self
.
stage
.
name
,
self
.
_internal
,
str
(
self
.
occurrence
)
])
return
phase_name
(
self
.
stage
,
self
,
self
.
occurrence
)
def
__getitem__
(
self
,
value
:
str
)
->
'
Action
'
:
return
self
.
_actions
[
value
]
...
...
@@ -198,7 +209,7 @@ class ChangePhaseAction(Action):
def
process
(
self
,
phase
:
'
Phase
'
)
->
Union
[
'
Phase
'
,
None
]:
if
isinstance
(
self
.
target_phase
,
str
):
return
phase
.
stage
.
current
(
self
.
target_phase
,
'
0
'
)
return
phase
.
stage
.
get_phase
(
phase_name
(
phase
.
stage
,
self
.
target_phase
,
0
)
)
return
self
.
target_phase
...
...
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