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
f0567060
There was a problem fetching the pipeline summary.
Commit
f0567060
authored
8 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[experiments] Allow blocks to be ordered properly on dumps
parent
343d1f20
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!204
[experiments] Allow blocks to be ordered properly on dumps
Pipeline
#
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beat/web/experiments/migrations/0007_auto_20160701_0909.py
+72
-0
72 additions, 0 deletions
beat/web/experiments/migrations/0007_auto_20160701_0909.py
beat/web/experiments/models.py
+8
-2
8 additions, 2 deletions
beat/web/experiments/models.py
with
80 additions
and
2 deletions
beat/web/experiments/migrations/0007_auto_20160701_0909.py
0 → 100644
+
72
−
0
View file @
f0567060
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-07-01 09:09
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
from
django.conf
import
settings
import
simplejson
import
beat.core.experiment
from
...common
import
storage
def
set_block_order
(
apps
,
schema_editor
):
'''
Set block order for existing experiments
'''
Experiment
=
apps
.
get_model
(
"
experiments
"
,
"
Experiment
"
)
Block
=
apps
.
get_model
(
"
experiments
"
,
"
Block
"
)
total
=
Experiment
.
objects
.
count
()
for
i
,
e
in
enumerate
(
Experiment
.
objects
.
order_by
(
'
id
'
)):
fullname
=
'
%s/%s/%s/%d/%s
'
%
(
e
.
author
.
username
,
e
.
toolchain
.
author
.
username
,
e
.
toolchain
.
name
,
e
.
toolchain
.
version
,
e
.
name
,
)
print
(
"
Updating blocks for experiment %d/%d (%s, id=%d)...
"
%
\
(
i
+
1
,
total
,
fullname
,
e
.
id
))
xp_decl
=
simplejson
.
loads
(
storage
.
get_file_content
(
e
,
'
declaration_file
'
))
tc_decl
=
simplejson
.
loads
(
storage
.
get_file_content
(
e
.
toolchain
,
'
declaration_file
'
))
xp
=
beat
.
core
.
experiment
.
Experiment
(
settings
.
PREFIX
,
(
xp_decl
,
tc_decl
))
if
xp
.
errors
:
message
=
"
The experiment `%s
'
isn
'
t valid (skipping
"
\
"
block update), due to the following errors:
\n
* %s
"
print
message
%
(
fullname
,
'
\n
*
'
.
join
(
xp
.
errors
))
continue
# Goes, in order, setting block inner order
for
order_0
,
block_name
in
enumerate
(
xp
.
setup
().
keys
()):
block
=
Block
.
objects
.
get
(
experiment
=
e
,
name
=
block_name
)
block
.
execution_order
=
order_0
+
1
block
.
save
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
experiments
'
,
'
0006_auto_20160630_1644
'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'
block
'
,
name
=
'
execution_order
'
,
field
=
models
.
PositiveIntegerField
(
blank
=
True
,
null
=
True
),
),
migrations
.
AlterModelOptions
(
name
=
'
block
'
,
options
=
{
'
ordering
'
:
[
'
experiment_id
'
,
'
execution_order
'
]},
),
migrations
.
RunPython
(
set_block_order
),
]
This diff is collapsed.
Click to expand it.
beat/web/experiments/models.py
+
8
−
2
View file @
f0567060
...
...
@@ -506,7 +506,8 @@ class Experiment(Shareable):
# Loads the experiment execution description, creating the Block's,
# BlockInput's and BlockOutput's as required.
for
block_name
,
description
in
corexp
.
setup
().
items
():
for
order_0
,
(
block_name
,
description
)
in
\
enumerate
(
corexp
.
setup
().
items
()):
# Checks that the Queue/Environment exists
job_description
=
description
[
'
configuration
'
]
...
...
@@ -553,6 +554,7 @@ class Experiment(Shareable):
b
=
Block
(
experiment
=
self
,
name
=
block_name
,
algorithm
=
algorithm
)
else
:
b
.
algorithm
=
algorithm
b
.
execution_order
=
order_0
+
1
b
.
command
=
simplejson
.
dumps
(
job_description
,
indent
=
4
)
b
.
status
=
Block
.
NOT_CACHED
b
.
analyzer
=
algorithm
.
analysis
()
...
...
@@ -919,6 +921,10 @@ class Block(models.Model):
symmetrical
=
False
,
)
# order of this block within the experiment - useful for the `backup'
# command, so we can dump the blocks in the right dependence order
execution_order
=
models
.
PositiveIntegerField
(
null
=
True
,
blank
=
True
)
objects
=
BlockManager
()
...
...
@@ -926,7 +932,7 @@ class Block(models.Model):
unique_together
=
(
'
experiment
'
,
'
name
'
)
# setup ordering so that the dump order respects self dependencies
ordering
=
[
'
id
'
]
ordering
=
[
'
experiment_id
'
,
'
execution_order
'
]
def
__str__
(
self
):
...
...
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