Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
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
SFB 1288 - INF
nopaque
Commits
1fa9cbc5
Commit
1fa9cbc5
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
pass job object instead of id.
parent
a5687a3f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/swarm.py
+5
-11
5 additions, 11 deletions
app/swarm.py
with
5 additions
and
11 deletions
app/swarm.py
+
5
−
11
View file @
1fa9cbc5
from
sqlalchemy
import
create_engine
from
sqlalchemy.orm
import
sessionmaker
import
docker
import
json
import
os
...
...
@@ -13,14 +11,13 @@ class Swarm:
self
.
docker
=
docker
.
from_env
()
def
init_app
(
self
,
app
):
engine
=
create_engine
(
app
.
config
[
'
SQLALCHEMY_DATABASE_URI
'
])
self
.
Session
=
sessionmaker
(
bind
=
engine
)
pass
'''
'
Swarm mode is intendet to run containers which serve a non terminating
'
service like a webserver. For processing an occuring job it is necessary
'
to use a one-shot container, which stops after the wrapped job process
is
'
completly executed. In order to run these one-shot containers in Swarm
'
to use a
n
one-shot container, which stops after the wrapped job process
'
is
completly executed. In order to run these one-shot containers in Swarm
'
mode, the following run method is implemented analog to the presented
'
implementation in Alex Ellis
'
blog post
"
One-shot containers on Docker
'
Swarm
"
¹.
...
...
@@ -28,13 +25,10 @@ class Swarm:
'
¹ https://blog.alexellis.io/containers-on-swarm/
'''
def
run
(
self
,
job
_id
):
def
run
(
self
,
job
):
'''
Input is a job
id
.
Input is a job.
'''
from
.models
import
Job
session
=
self
.
Session
()
job
=
session
.
query
(
Job
).
filter_by
(
id
=
job_id
).
first
()
# Prepare argument values needed for the service creation.
service_args
=
json
.
loads
(
job
.
service_args
)
_command
=
(
job
.
service
...
...
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