Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
datascience
balsamDEPRECATED
Commits
0a3dd01f
Commit
0a3dd01f
authored
Nov 21, 2016
by
jtchilders
Browse files
changed id to job_id, change serialize method of balsam job
parent
6b5a4867
Changes
1
Hide whitespace changes
Inline
Side-by-side
balsam/BalsamJobStatus.py
View file @
0a3dd01f
import
common.Serializer
as
Serializer
from
django.core
import
serializers
import
logging
,
sys
logger
=
logging
.
getLogger
(
__name__
)
from
common
import
Serializer
class
SerializeFailed
(
Exception
):
pass
class
DeserializeFailed
(
Exception
):
pass
class
BalsamJobStatus
:
def
__init__
(
self
,
job
=
None
,
message
=
None
):
self
.
id
=
None
self
.
job_id
=
None
self
.
serialized_job
=
None
self
.
message
=
message
if
job
is
not
None
:
self
.
set_job
(
job
)
def
set_job
(
self
,
job
):
self
.
id
=
job
.
balsam_
job_id
self
.
job_
id
=
job
.
job_id
try
:
self
.
serialized_job
=
serializers
.
serialize
(
'json'
,[
job
]
)
self
.
serialized_job
=
job
.
serialize
(
)
except
Exception
,
e
:
logger
.
exception
(
'serialize failed: '
+
str
(
job
.
__dict__
))
raise
SerializeFailed
(
'Received exception while serializing BalsamJob'
)
def
get_job
(
self
):
def
get_job
(
self
,
job
):
if
self
.
serialized_job
is
not
None
:
try
:
balsam_jobs
=
serializers
.
deserialize
(
'json'
,
self
.
serialized_job
)
return
balsam_jobs
.
next
().
object
job
.
deserialize
(
self
.
serialized_job
)
return
job
except
Exception
,
e
:
logger
.
exception
(
'deserialize failed: '
+
str
(
self
.
serialized_job
))
raise
DeserializeFailed
(
'Received exception while deserializing BalsamJob'
)
...
...
@@ -42,7 +42,7 @@ class BalsamJobStatus:
def
deserialize
(
self
,
text
):
try
:
self
.
__dict__
=
Serializer
.
deserialize
(
text
)
self
.
id
=
int
(
str
(
self
.
id
))
self
.
job_
id
=
int
(
str
(
self
.
job_
id
))
except
Exception
,
e
:
logger
.
exception
(
'deserialize failed'
)
raise
DeserializeFailed
(
'Received exception while deserializing BalsamJobStatus: '
+
str
(
e
))
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