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
85b2100e
Commit
85b2100e
authored
5 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Patches
Plain Diff
Add to_dict methods
parent
9b4f29a8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/models.py
+26
-2
26 additions, 2 deletions
app/models.py
with
26 additions
and
2 deletions
app/models.py
+
26
−
2
View file @
85b2100e
...
...
@@ -252,7 +252,7 @@ class AnonymousUser(AnonymousUserMixin):
class
JobInput
(
db
.
Model
):
"""
Class to define
File
s.
Class to define
JobInput
s.
"""
__tablename__
=
'
job_inputs
'
# Primary key
...
...
@@ -260,10 +260,21 @@ class JobInput(db.Model):
filename
=
db
.
Column
(
db
.
String
(
255
))
job_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
jobs.id
'
))
def
__repr__
(
self
):
"""
String representation of the JobInput. For human readability.
"""
return
'
<JobInput %r>
'
%
self
.
filename
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
'
filename
'
:
self
.
filename
,
'
job_id
'
:
self
.
job_id
}
class
JobResult
(
db
.
Model
):
"""
Class to define
File
s.
Class to define
JobResult
s.
"""
__tablename__
=
'
job_results
'
# Primary key
...
...
@@ -271,6 +282,17 @@ class JobResult(db.Model):
filename
=
db
.
Column
(
db
.
String
(
255
))
job_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'
jobs.id
'
))
def
__repr__
(
self
):
"""
String representation of the JobResult. For human readability.
"""
return
'
<JobResult %r>
'
%
self
.
filename
def
to_dict
(
self
):
return
{
'
id
'
:
self
.
id
,
'
filename
'
:
self
.
filename
,
'
job_id
'
:
self
.
job_id
}
class
Job
(
db
.
Model
):
"""
...
...
@@ -319,8 +341,10 @@ class Job(db.Model):
'
description
'
:
self
.
description
,
'
end_date
'
:
(
self
.
end_date
.
timestamp
()
if
self
.
end_date
else
None
),
'
inputs
'
:
[
input
.
to_dict
()
for
input
in
self
.
inputs
],
'
mem_mb
'
:
self
.
mem_mb
,
'
n_cores
'
:
self
.
n_cores
,
'
results
'
:
[
result
.
to_dict
()
for
result
in
self
.
results
],
'
service
'
:
self
.
service
,
'
service_args
'
:
self
.
service_args
,
'
service_version
'
:
self
.
service_version
,
...
...
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