Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
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
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
6c3fbefb
Commit
6c3fbefb
authored
1 year ago
by
Mohammad Torkashvand
Browse files
Options
Downloads
Patches
Plain Diff
make test stuff compatible with orchestrator-core 1.3.0
parent
ab58c961
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!72
Feature/nat 260 unit test
Pipeline
#84158
passed
1 year ago
Stage: tox
Stage: documentation
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/workflows/__init__.py
+18
-9
18 additions, 9 deletions
test/workflows/__init__.py
with
18 additions
and
9 deletions
test/workflows/__init__.py
+
18
−
9
View file @
6c3fbefb
...
...
@@ -7,13 +7,13 @@ from uuid import uuid4
import
structlog
from
orchestrator.db
import
ProcessTable
from
orchestrator.forms
import
post_process
from
orchestrator.services.processes
import
StateMerger
,
_db_create_process
from
orchestrator.types
import
FormGenerator
,
InputForm
,
State
from
orchestrator.utils.json
import
json_dumps
,
json_loads
from
orchestrator.workflow
import
Process
as
WFProcess
from
orchestrator.workflow
import
ProcessStat
,
Step
,
Success
,
Workflow
,
runwf
from
orchestrator.workflows
import
ALL_WORKFLOWS
,
LazyWorkflowInstance
,
get_workflow
from
pydantic_forms.core
import
post_form
logger
=
structlog
.
get_logger
(
__name__
)
...
...
@@ -173,20 +173,24 @@ def run_workflow(workflow_key: str, input_data: Union[State, List[State]]) -> Tu
step_log
:
List
[
Tuple
[
Step
,
WFProcess
]]
=
[]
pid
=
uuid4
()
p
rocess_
id
=
uuid4
()
workflow
=
get_workflow
(
workflow_key
)
assert
workflow
,
"
Workflow does not exist
"
initial_state
=
{
"
process_id
"
:
pid
,
"
process_id
"
:
p
rocess_
id
,
"
reporter
"
:
user
,
"
workflow_name
"
:
workflow_key
,
"
workflow_target
"
:
workflow
.
target
,
}
user_input
=
post_
process
(
workflow
.
initial_input_form
,
initial_state
,
user_data
)
user_input
=
post_
form
(
workflow
.
initial_input_form
,
initial_state
,
user_data
)
pstat
=
ProcessStat
(
pid
,
workflow
=
workflow
,
state
=
Success
({
**
user_input
,
**
initial_state
}),
log
=
workflow
.
steps
,
current_user
=
user
process_id
,
workflow
=
workflow
,
state
=
Success
({
**
user_input
,
**
initial_state
}),
log
=
workflow
.
steps
,
current_user
=
user
,
)
_db_create_process
(
pstat
)
...
...
@@ -200,17 +204,22 @@ def resume_workflow(
process
:
ProcessStat
,
step_log
:
List
[
Tuple
[
Step
,
WFProcess
]],
input_data
:
State
)
->
Tuple
[
WFProcess
,
List
]:
# ATTENTION!! This code needs to be as similar as possible to `server.services.processes.resume_process`
# The main differences are: we use a different step log function and we don't run in
# a sepperate thread
# The main differences are: we use a different step log function, and we don't run in a separate thread
user_data
=
_sanitize_input
(
input_data
)
persistent
=
list
(
filter
(
lambda
p
:
not
(
p
[
1
].
isfailed
()
or
p
[
1
].
issuspend
()
or
p
[
1
].
iswaiting
()),
step_log
))
nr_of_steps_done
=
len
(
persistent
)
remaining_steps
=
process
.
workflow
.
steps
[
nr_of_steps_done
:]
_
,
current_state
=
step_log
[
-
1
]
# Make sure we get the last state from the suspend step (since we removed it before)
if
step_log
and
step_log
[
-
1
][
1
].
issuspend
():
_
,
current_state
=
step_log
[
-
1
]
elif
persistent
:
_
,
current_state
=
persistent
[
-
1
]
else
:
current_state
=
Success
({})
user_input
=
post_
process
(
remaining_steps
[
0
].
form
,
current_state
.
unwrap
(),
user_data
)
user_input
=
post_
form
(
remaining_steps
[
0
].
form
,
current_state
.
unwrap
(),
user_data
)
state
=
current_state
.
map
(
lambda
state
:
StateMerger
.
merge
(
deepcopy
(
state
),
user_input
))
updated_process
=
process
.
update
(
log
=
remaining_steps
,
state
=
state
)
...
...
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