Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Medizinische Informatik - Öffentliche Projekte
UMG MeDIC
MeDIC Technik
AW Agents
File Mover
Commits
6cf4cd16
Commit
6cf4cd16
authored
May 22, 2021
by
Markus Suhr
Browse files
Added AW state handling via memory attribute to enable distinction between multiple workflows
parent
3fa54b76
Pipeline
#198131
passed with stage
in 45 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
CHANGELOG.md
View file @
6cf4cd16
...
...
@@ -26,7 +26,7 @@ _Types of changes_:
### Changed
*
Switched from synchronous to
**asynchronous file processing**
: instead of moving
(copying, deleting) files procedurally when a "receive" or "chec
h
" HTTP request is handled, jobs now will be stored in
(copying, deleting) files procedurally when a "receive" or "chec
k
" HTTP request is handled, jobs now will be stored in
a
**Redis**
database and will be executed as background tasks by the FastAPI engine.
See https://fastapi.tiangolo.com/tutorial/background-tasks/
for details.
...
...
mover/main.py
View file @
6cf4cd16
...
...
@@ -78,6 +78,16 @@ def receive(payload: RequestReceive, background_tasks: BackgroundTasks):
response
=
ResponseReceiveCheck
()
response
.
result
.
logs
=
[
f
"Job with id
{
task_id
}
added to queue."
]
# This Remote Agent may be part of multiple ActiveWorkflow Workflows
# We have to rely on the AW memory to store job-IDs which are part of the correct Workflow
memory
=
payload
.
params
.
memory
if
'jobs'
in
memory
and
type
(
memory
[
'jobs'
])
is
list
:
memory
[
'jobs'
].
append
(
task_id
)
else
:
memory
[
'jobs'
]
=
[
task_id
]
response
.
result
.
memory
=
memory
return
JSONResponse
(
content
=
response
.
dict
())
...
...
@@ -98,21 +108,32 @@ def check(payload: RequestCheck):
content
=
{
'result'
:
ResultReceiveCheck
(
errors
=
[
info_message
]).
dict
()}
)
# This Remote Agent may be part of multiple ActiveWorkflow Workflows
# We have to rely on the AW memory to store job-IDs which are part of the correct Workflow
memory
=
payload
.
params
.
memory
if
'jobs'
not
in
memory
or
type
(
memory
[
'jobs'
])
is
not
list
:
memory
[
'jobs'
]
=
[]
q
=
Queue
()
response
=
ResponseReceiveCheck
()
done
=
[]
for
job_id
in
q
.
keys
():
data
=
q
.
get
(
job_id
)
if
'result'
in
data
.
keys
():
r
=
data
[
'result'
]
response
.
result
.
logs
.
extend
(
r
[
'logs'
])
response
.
result
.
errors
.
extend
(
r
[
'errors'
])
response
.
result
.
messages
.
extend
(
r
[
'messages'
])
done
.
append
(
job_id
)
else
:
response
.
result
.
logs
.
append
(
f
"Job with id
{
job_id
}
queued since
{
data
[
'received'
]
}
."
)
job_id
=
job_id
.
decode
()
if
job_id
in
memory
[
'jobs'
]:
if
'result'
in
data
.
keys
():
r
=
data
[
'result'
]
response
.
result
.
logs
.
extend
(
r
[
'logs'
])
response
.
result
.
errors
.
extend
(
r
[
'errors'
])
response
.
result
.
messages
.
extend
(
r
[
'messages'
])
done
.
append
(
job_id
)
else
:
response
.
result
.
logs
.
append
(
f
"Job with id
{
job_id
}
queued since
{
data
[
'received'
]
}
."
)
for
job_id
in
done
:
q
.
delete
(
job_id
)
memory
[
'jobs'
].
remove
(
job_id
)
response
.
result
.
memory
=
memory
return
JSONResponse
(
content
=
response
.
dict
())
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment