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
116e500c
Commit
116e500c
authored
7 years ago
by
Jaden Diefenbaugh
Browse files
Options
Downloads
Patches
Plain Diff
add notes to migration script and convert aliases appropriately
parent
a99dcc2b
No related branches found
No related tags found
1 merge request
!223
Reports overhaul
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beat/web/reports/migrations/0004_auto_20170410_1121.py
+24
-3
24 additions, 3 deletions
beat/web/reports/migrations/0004_auto_20170410_1121.py
with
24 additions
and
3 deletions
beat/web/reports/migrations/0004_auto_20170410_1121.py
+
24
−
3
View file @
116e500c
...
@@ -6,6 +6,8 @@ from django.db import migrations
...
@@ -6,6 +6,8 @@ from django.db import migrations
import
json
import
json
import
re
import
re
# parses a table from the old representation (a list of column objects)
# and returns a table in the new representation
def
parse_table
(
table
,
precision
):
def
parse_table
(
table
,
precision
):
conv_table
=
{
conv_table
=
{
'
fields
'
:
[
'
Experiment
'
],
'
fields
'
:
[
'
Experiment
'
],
...
@@ -34,6 +36,8 @@ def parse_table(table, precision):
...
@@ -34,6 +36,8 @@ def parse_table(table, precision):
return
conv_table
return
conv_table
# parses a plot from the old representation
# and returns a plot in the new representation
def
parse_plot
(
plot
):
def
parse_plot
(
plot
):
conv_plot
=
{
conv_plot
=
{
'
name
'
:
plot
[
'
data
'
][
'
output
'
][
0
],
'
name
'
:
plot
[
'
data
'
][
'
output
'
][
0
],
...
@@ -41,20 +45,27 @@ def parse_plot(plot):
...
@@ -41,20 +45,27 @@ def parse_plot(plot):
}
}
return
conv_plot
return
conv_plot
# helper func to build the experiment's full name
def
experiment_fullname
(
exp
):
def
experiment_fullname
(
exp
):
return
'
%s/%s/%s/%s/%s
'
%
(
exp
.
author
.
username
,
exp
.
toolchain
.
author
.
username
,
exp
.
toolchain
.
name
,
exp
.
toolchain
.
version
,
exp
.
name
)
return
'
%s/%s/%s/%s/%s
'
%
(
exp
.
author
.
username
,
exp
.
toolchain
.
author
.
username
,
exp
.
toolchain
.
name
,
exp
.
toolchain
.
version
,
exp
.
name
)
# helper func to build the analyzer's full name
def
analyzer_fullname
(
report
):
def
analyzer_fullname
(
report
):
return
'
%s/%s/%s
'
%
(
report
.
analyzer
.
author
.
username
,
report
.
analyzer
.
name
,
report
.
analyzer
.
version
)
return
'
%s/%s/%s
'
%
(
report
.
analyzer
.
author
.
username
,
report
.
analyzer
.
name
,
report
.
analyzer
.
version
)
# converts an old report into the new report format
def
move_content_to_groups_format
(
apps
,
schema_editor
):
def
move_content_to_groups_format
(
apps
,
schema_editor
):
Report
=
apps
.
get_model
(
'
reports
'
,
'
Report
'
)
Report
=
apps
.
get_model
(
'
reports
'
,
'
Report
'
)
for
report
in
Report
.
objects
.
all
():
for
report
in
Report
.
objects
.
all
():
# all of the changes are in the report's content field
report_content
=
json
.
loads
(
report
.
content
)
report_content
=
json
.
loads
(
report
.
content
)
# convert to groups format
# convert to groups format, but don't touch any report thats
# already using the new system
if
'
groups
'
not
in
report_content
:
if
'
groups
'
not
in
report_content
:
exps
=
report
.
experiments
.
all
()
# format:
# ----
# groups: {
# groups: {
# group1 : {
# group1 : {
# experiments: [],
# experiments: [],
...
@@ -65,17 +76,27 @@ def move_content_to_groups_format(apps, schema_editor):
...
@@ -65,17 +76,27 @@ def move_content_to_groups_format(apps, schema_editor):
# },
# },
# ...
# ...
# }
# }
# ----
exps
=
report
.
experiments
.
all
()
obj
=
{}
obj
=
{}
groups
=
{}
groups
=
{}
# default to just one group that contains all experiments/items
group1
=
{
group1
=
{
# list of experiments in the group
'
experiments
'
:
[
experiment_fullname
(
e
)
for
e
in
exps
],
'
experiments
'
:
[
experiment_fullname
(
e
)
for
e
in
exps
],
'
reportItems
'
:
[],
'
reportItems
'
:
[],
# analyzer of the report
'
analyzer
'
:
analyzer_fullname
(
report
)
if
report
.
analyzer
else
''
,
'
analyzer
'
:
analyzer_fullname
(
report
)
if
report
.
analyzer
else
''
,
'
aliases
'
:
{},
'
aliases
'
:
{},
'
idx
'
:
1
'
idx
'
:
1
}
}
old_aliases
=
report_content
[
'
alias_experiments
'
]
if
'
alias_experiments
'
in
report_content
else
{}
# assign aliases
get_alias
=
lambda
exp_name
:
old_aliases
[
exp_name
]
if
exp_name
in
old_aliases
else
None
for
e
in
exps
:
for
e
in
exps
:
group1
[
'
aliases
'
][
experiment_fullname
(
e
)]
=
e
.
name
fullname
=
experiment_fullname
(
e
)
group1
[
'
aliases
'
][
fullname
]
=
get_alias
(
fullname
)
or
e
.
name
count_tables
=
0
count_tables
=
0
count_plots
=
0
count_plots
=
0
...
...
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