Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
beat.web
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
beat
beat.web
Commits
060f71d4
Commit
060f71d4
authored
8 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[backend] Fix result to job/split relationship
parent
c71f3a2c
No related branches found
No related tags found
1 merge request
!194
Scheduler
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beat/web/backend/migrations/0002_scheduler_addons.py
+2
-2
2 additions, 2 deletions
beat/web/backend/migrations/0002_scheduler_addons.py
beat/web/backend/models.py
+9
-14
9 additions, 14 deletions
beat/web/backend/models.py
with
11 additions
and
16 deletions
beat/web/backend/migrations/0002_scheduler_addons.py
+
2
−
2
View file @
060f71d4
...
...
@@ -143,7 +143,7 @@ class Migration(migrations.Migration):
(
'
split_errors
'
,
models
.
PositiveIntegerField
(
default
=
0
)),
(
'
block
'
,
models
.
OneToOneField
(
related_name
=
'
job
'
,
on_delete
=
models
.
deletion
.
CASCADE
,
to
=
'
experiments.Block
'
,
null
=
True
)),
(
'
parent
'
,
models
.
OneToOneField
(
related_name
=
'
child
'
,
to
=
'
backend.Job
'
,
null
=
True
,
on_delete
=
models
.
deletion
.
SET_NULL
)),
(
'
result
'
,
models
.
ForeignKey
(
to
=
'
backend.Result
'
,
null
=
True
)),
(
'
result
'
,
models
.
OneToOneField
(
to
=
'
backend.Result
'
,
null
=
True
,
on_delete
=
models
.
deletion
.
CASCADE
,
related_name
=
'
job
'
)),
],
),
migrations
.
CreateModel
(
...
...
@@ -159,7 +159,7 @@ class Migration(migrations.Migration):
(
'
process_id
'
,
models
.
PositiveIntegerField
(
null
=
True
)),
(
'
job
'
,
models
.
ForeignKey
(
related_name
=
'
splits
'
,
to
=
'
backend.Job
'
,
null
=
True
)),
(
'
worker
'
,
models
.
ForeignKey
(
related_name
=
'
splits
'
,
on_delete
=
models
.
deletion
.
SET_NULL
,
to
=
'
backend.Worker
'
,
null
=
True
)),
(
'
result
'
,
models
.
ForeignKey
(
to
=
'
backend.Result
'
,
related_name
=
'
split
s
'
,
null
=
True
)),
(
'
result
'
,
models
.
OneToOneField
(
to
=
'
backend.Result
'
,
related_name
=
'
split
'
,
null
=
True
,
on_delete
=
models
.
deletion
.
CASCADE
)),
],
),
migrations
.
AlterUniqueTogether
(
...
...
This diff is collapsed.
Click to expand it.
beat/web/backend/models.py
+
9
−
14
View file @
060f71d4
...
...
@@ -476,7 +476,8 @@ class Job(models.Model):
status
=
models
.
CharField
(
max_length
=
1
,
choices
=
STATUS
,
default
=
QUEUED
)
result
=
models
.
ForeignKey
(
Result
,
null
=
True
,
on_delete
=
models
.
CASCADE
)
result
=
models
.
OneToOneField
(
Result
,
null
=
True
,
on_delete
=
models
.
CASCADE
,
related_name
=
'
job
'
)
runnable_date
=
models
.
DateTimeField
(
null
=
True
,
blank
=
True
)
...
...
@@ -658,17 +659,12 @@ class Job(models.Model):
self
.
child
.
parent
=
parent
else
:
#child is the new parent
self
.
child
.
parent
=
None
else
:
self
.
child
.
copy
(
job
)
self
.
child
.
_cascade_updates
()
self
.
child
.
copy
(
self
)
if
self
.
parent
and
self
.
status
==
Job
.
CANCELLED
:
self
.
parent
=
None
# update state of parent block/experiment
self
.
block
.
_update_state
()
@transaction.atomic
def
_update_state
(
self
):
...
...
@@ -710,8 +706,9 @@ class Job(models.Model):
self
.
status
=
Job
.
QUEUED
# if required, erase dangling files, update own results
timings
=
None
if
self
.
done
():
timings
=
None
# compute final timings and update parent block
if
self
.
status
!=
Job
.
SKIPPED
:
diff_timings
=
self
.
_merge_results
()
self
.
end_date
=
self
.
splits
.
order_by
(
'
-end_date
'
).
\
...
...
@@ -728,11 +725,9 @@ class Job(models.Model):
self
.
runnable_date
=
None
self
.
erase_dangling_files
()
# compute final timings and update parent block
self
.
save
()
# updates the dependents and child state
self
.
save
()
self
.
block
.
_update_state
(
timings
)
self
.
_cascade_updates
()
...
...
@@ -827,8 +822,8 @@ class JobSplit(models.Model):
status
=
models
.
CharField
(
max_length
=
1
,
choices
=
Job
.
STATUS
,
default
=
Job
.
QUEUED
)
result
=
models
.
ForeignKey
(
Result
,
null
=
True
,
on_delete
=
models
.
CASCADE
,
related_name
=
'
split
s
'
)
result
=
models
.
OneToOneField
(
Result
,
null
=
True
,
on_delete
=
models
.
CASCADE
,
related_name
=
'
split
'
)
start_date
=
models
.
DateTimeField
(
null
=
True
)
...
...
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