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
Martin Mareš
Odevzdávací Systém MO
Commits
42ff29b7
Commit
42ff29b7
authored
1 year ago
by
Martin Mareš
Browse files
Options
Downloads
Patches
Plain Diff
Jobs: Dřívějšímu "retry" nyní říkáme "restart"
parent
fcd0d62b
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/run-jobs
+4
-4
4 additions, 4 deletions
bin/run-jobs
mo/jobs/__init__.py
+5
-5
5 additions, 5 deletions
mo/jobs/__init__.py
with
9 additions
and
9 deletions
bin/run-jobs
+
4
−
4
View file @
42ff29b7
...
...
@@ -6,18 +6,18 @@ import argparse
parser
=
argparse
.
ArgumentParser
(
description
=
'
Spustí joby ve frontě
'
)
parser
.
add_argument
(
'
-j
'
,
'
--job
'
,
type
=
int
,
metavar
=
'
ID
'
,
help
=
'
Spustí konkrétní job
'
)
parser
.
add_argument
(
'
-r
'
,
'
--re
try
'
,
default
=
False
,
action
=
'
store_true
'
,
help
=
'
Znovu spustí dokončený job
'
)
parser
.
add_argument
(
'
-r
'
,
'
--re
start
'
,
default
=
False
,
action
=
'
store_true
'
,
help
=
'
Znovu spustí dokončený job
'
)
args
=
parser
.
parse_args
()
init_standalone
()
if
args
.
job
is
None
:
if
args
.
re
try
:
die
(
"
Přepínač --re
try
lze použít jen s --job
"
)
if
args
.
re
start
:
die
(
"
Přepínač --re
start
lze použít jen s --job
"
)
mo
.
jobs
.
process_jobs
()
else
:
tj
=
mo
.
jobs
.
TheJob
(
args
.
job
)
if
not
tj
.
load
():
die
(
"
Tento job neexistuje
"
)
tj
.
run
(
re
try
=
args
.
re
try
)
tj
.
run
(
re
start
=
args
.
re
start
)
This diff is collapsed.
Click to expand it.
mo/jobs/__init__.py
+
5
−
5
View file @
42ff29b7
...
...
@@ -116,19 +116,19 @@ class TheJob:
logger
.
info
(
f
'
{
self
.
log_prefix
}
>>
{
msg
}
'
)
self
.
errors
.
append
(
msg
)
def
_check_runnable
(
self
,
re
try
:
bool
)
->
Optional
[
str
]:
def
_check_runnable
(
self
,
re
start
:
bool
)
->
Optional
[
str
]:
s
=
self
.
job
.
state
if
s
==
db
.
JobState
.
ready
:
if
s
in
(
db
.
JobState
.
ready
,
db
.
JobState
.
soft_error
)
:
return
None
elif
s
==
db
.
JobState
.
running
:
# Může se stát, že ho mezitím začal vyřizovat jiný proces
return
'
právě běží
'
elif
s
in
(
db
.
JobState
.
done
,
db
.
JobState
.
failed
,
db
.
JobState
.
internal_error
):
return
None
if
re
try
else
'
je už hotový
'
return
None
if
re
start
else
'
je už hotový
'
else
:
return
'
je v neznámém stavu
'
def
run
(
self
,
re
try
:
bool
=
False
):
def
run
(
self
,
re
start
:
bool
=
False
):
sess
=
db
.
get_session
()
if
not
self
.
load
():
# Někdo ho mezitím smazal
...
...
@@ -136,7 +136,7 @@ class TheJob:
sess
.
rollback
()
return
reject_reason
=
self
.
_check_runnable
(
re
try
)
reject_reason
=
self
.
_check_runnable
(
re
start
)
if
reject_reason
is
not
None
:
logger
.
info
(
f
'
{
self
.
log_prefix
}
{
reject_reason
}
'
)
sess
.
rollback
()
...
...
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