Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CloWM Workflow Service
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
Looking for advice? Join the
Matrix channel for GitLab users in Bielefeld
!
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Computational Metagenomics
CloWM
CloWM Workflow Service
Commits
04d18fb2
Verified
Commit
04d18fb2
authored
2 years ago
by
Daniel Göbel
Browse files
Options
Downloads
Patches
Plain Diff
Add workflow id to WorkflowExecutionOut scheme
#25
parent
c4c14e72
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/api/endpoints/workflow_execution.py
+12
-4
12 additions, 4 deletions
app/api/endpoints/workflow_execution.py
app/crud/crud_workflow_execution.py
+8
-3
8 additions, 3 deletions
app/crud/crud_workflow_execution.py
app/schemas/workflow_execution.py
+14
-2
14 additions, 2 deletions
app/schemas/workflow_execution.py
with
34 additions
and
9 deletions
app/api/endpoints/workflow_execution.py
+
12
−
4
View file @
04d18fb2
...
...
@@ -131,7 +131,7 @@ async def start_workflow(
slurm_client
=
slurm_client
,
)
return
execution
return
WorkflowExecutionOut
.
from_db_model
(
execution
,
workflow_id
=
workflow_version
.
workflow_id
)
@router.post
(
...
...
@@ -229,7 +229,7 @@ async def start_arbitrary_workflow(
slurm_client
=
slurm_client
,
)
return
execution
return
WorkflowExecutionOut
.
from_db_model
(
execution
)
@router.get
(
""
,
status_code
=
status
.
HTTP_200_OK
,
summary
=
"
Get all workflow executions
"
)
...
...
@@ -283,7 +283,12 @@ async def list_workflow_executions(
executions
=
await
CRUDWorkflowExecution
.
list
(
db
,
uid
=
user_id
,
workflow_version_id
=
workflow_version_id
,
status_list
=
execution_status
)
return
executions
return
[
WorkflowExecutionOut
.
from_db_model
(
execution
,
execution
.
workflow_version
.
workflow_id
if
execution
.
workflow_version
is
not
None
else
None
)
for
execution
in
executions
]
@router.get
(
"
/{eid}
"
,
status_code
=
status
.
HTTP_200_OK
,
summary
=
"
Get a workflow execution
"
)
...
...
@@ -313,7 +318,10 @@ async def get_workflow_execution(
"""
rbac_operation
=
"
read
"
if
workflow_execution
.
user_id
==
current_user
.
uid
else
"
read_any
"
await
authorization
(
rbac_operation
)
return
workflow_execution
return
WorkflowExecutionOut
.
from_db_model
(
workflow_execution
,
workflow_execution
.
workflow_version
.
workflow_id
if
workflow_execution
.
workflow_version
is
not
None
else
None
,
)
@router.delete
(
"
/{eid}
"
,
status_code
=
status
.
HTTP_204_NO_CONTENT
,
summary
=
"
Delete a workflow execution
"
)
...
...
This diff is collapsed.
Click to expand it.
app/crud/crud_workflow_execution.py
+
8
−
3
View file @
04d18fb2
...
...
@@ -3,6 +3,7 @@ from uuid import UUID
from
clowmdb.models
import
WorkflowExecution
from
sqlalchemy
import
delete
,
or_
,
select
,
update
from
sqlalchemy.ext.asyncio
import
AsyncSession
from
sqlalchemy.orm
import
joinedload
from
app.schemas.workflow_execution
import
DevWorkflowExecutionIn
,
WorkflowExecutionIn
...
...
@@ -68,7 +69,11 @@ class CRUDWorkflowExecution:
The workflow execution with the given id if it exists, None otherwise
"""
eid
=
execution_id
.
bytes
if
isinstance
(
execution_id
,
UUID
)
else
execution_id
stmt
=
select
(
WorkflowExecution
).
where
(
WorkflowExecution
.
_execution_id
==
eid
)
stmt
=
(
select
(
WorkflowExecution
)
.
where
(
WorkflowExecution
.
_execution_id
==
eid
)
.
options
(
joinedload
(
WorkflowExecution
.
workflow_version
))
)
execution
=
(
await
db
.
execute
(
stmt
)).
scalar
()
return
execution
...
...
@@ -95,10 +100,10 @@ class CRUDWorkflowExecution:
Returns
-------
workflow_executions : list[clowmdb.models.WorkflowExecution
.WorkflowExecutionStatus
]
workflow_executions : list[clowmdb.models.WorkflowExecution]
List of all workflow executions with applied filters.
"""
stmt
=
select
(
WorkflowExecution
)
stmt
=
select
(
WorkflowExecution
)
.
options
(
joinedload
(
WorkflowExecution
.
workflow_version
))
if
uid
is
not
None
:
stmt
=
stmt
.
where
(
WorkflowExecution
.
user_id
==
uid
)
if
workflow_version_id
is
not
None
:
...
...
This diff is collapsed.
Click to expand it.
app/schemas/workflow_execution.py
+
14
−
2
View file @
04d18fb2
...
...
@@ -55,9 +55,21 @@ class WorkflowExecutionOut(_BaseWorkflowExecution):
workflow_version_id
:
str
|
None
=
Field
(
# type: ignore[assignment]
...,
description
=
"
Workflow version git commit hash
"
,
example
=
"
ba8bcd9294c2c96aedefa1763a84a18077c50c0f
"
)
workflow_id
:
UUID
|
None
=
Field
(
...,
description
=
"
Id of the workflow
"
,
example
=
"
0cc78936-381b-4bdd-999d-736c40591078
"
)
class
Config
:
orm_mode
=
True
@staticmethod
def
from_db_model
(
workflow_execution
:
WorkflowExecution
,
workflow_id
:
UUID
|
None
=
None
)
->
"
WorkflowExecutionOut
"
:
return
WorkflowExecutionOut
(
execution_id
=
workflow_execution
.
execution_id
,
user_id
=
workflow_execution
.
user_id
,
start_time
=
workflow_execution
.
start_time
,
end_time
=
workflow_execution
.
end_time
,
status
=
workflow_execution
.
status
,
workflow_version_id
=
workflow_execution
.
workflow_version_id
,
workflow_id
=
workflow_id
,
)
class
DevWorkflowExecutionIn
(
BaseModel
):
...
...
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