Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Odevzdávací Systém MO
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MO-P
Odevzdávací Systém MO
Commits
e08a2edf
Commit
e08a2edf
authored
Jan 16, 2021
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Jobs: V průběhu jobu se sbírají hlášení o chybách
parent
5b166d74
Branches
Branches containing commit
No related tags found
3 merge requests
!19
Reforma vyhodnocování práv
,
!18
Dávky okolo feedbacku
,
!17
Výsledkovka pomocí mo.web.table
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
mo/jobs/__init__.py
+14
-3
14 additions, 3 deletions
mo/jobs/__init__.py
with
14 additions
and
3 deletions
mo/jobs/__init__.py
+
14
−
3
View file @
e08a2edf
...
...
@@ -4,7 +4,7 @@ from datetime import timedelta
import
os
import
secrets
from
sqlalchemy
import
or_
from
typing
import
Optional
,
Dict
,
Callable
from
typing
import
Optional
,
Dict
,
Callable
,
List
import
mo
import
mo.config
as
config
...
...
@@ -28,10 +28,12 @@ class TheJob:
job
:
db
.
Job
job_id
:
Optional
[
int
]
errors
:
List
[
str
]
def
__init__
(
self
,
job_id
:
Optional
[
int
]
=
None
):
"""
Pokud chceme pracovat s existujícím jobem, zadáme jeho ID.
"""
self
.
job_id
=
job_id
self
.
errors
=
[]
def
load
(
self
)
->
db
.
Job
:
sess
=
db
.
get_session
()
...
...
@@ -95,6 +97,9 @@ class TheJob:
logger
.
info
(
f
'
Job: Ruším job #
{
self
.
job
.
job_id
}
'
)
return
self
.
_finish_remove
()
def
error
(
self
,
msg
):
self
.
errors
.
append
(
msg
)
def
run
(
self
):
sess
=
db
.
get_session
()
if
not
self
.
load
()
or
self
.
job
.
state
!=
db
.
JobState
.
ready
:
...
...
@@ -110,11 +115,17 @@ class TheJob:
try
:
_handler_table
[
job
.
type
](
self
)
if
self
.
errors
:
logger
.
info
(
f
'
Job: Neúspěšně dokončen job #
{
job
.
job_id
}
'
)
job
.
state
=
db
.
JobState
.
failed
job
.
out_json
=
{
'
errors
'
:
self
.
errors
}
else
:
logger
.
info
(
f
'
Job: Úspěšně dokončen job #
{
job
.
job_id
}
'
)
job
.
state
=
db
.
JobState
.
done
except
Exception
as
e
:
logger
.
error
(
f
'
Job: Chyba při zpracování jobu #
{
job
.
job_id
}
: %s
'
,
e
,
exc_info
=
e
)
job
.
state
=
db
.
JobState
.
failed
job
.
out_json
=
{
'
errors
'
:
'
Interní chyba, informujte prosím správce systému.
'
}
return
job
.
finished_at
=
mo
.
util
.
get_now
()
...
...
...
...
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
sign in
to comment