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
8c34a255
Commit
8c34a255
authored
8 years ago
by
Jaden Diefenbaugh
Browse files
Options
Downloads
Patches
Plain Diff
added data migration script for reports
parent
50d9581e
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
+121
-0
121 additions, 0 deletions
beat/web/reports/migrations/0004_auto_20170410_1121.py
with
121 additions
and
0 deletions
beat/web/reports/migrations/0004_auto_20170410_1121.py
0 → 100644
+
121
−
0
View file @
8c34a255
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2017-04-10 11:21
from
__future__
import
unicode_literals
from
django.db
import
migrations
import
json
import
re
def
parse_table
(
table
,
precision
):
conv_table
=
{
'
fields
'
:
[
'
Experiment
'
],
'
precision
'
:
precision
}
for
row
in
table
:
name
=
row
[
'
name
'
]
name
=
re
.
sub
(
r
'
\[.*\]$
'
,
''
,
name
)
if
name
==
'
experiment
'
:
continue
if
name
==
'
experiment.execution_time
'
or
name
==
'
execution_time
'
:
name
=
'
total_execution_time
'
elif
re
.
match
(
r
'
^execution_time\.
'
,
name
):
name
=
re
.
sub
(
r
'
execution_time
'
,
'
linear_execution_time
'
,
name
)
if
name
.
startswith
(
'
experiment.
'
):
name
=
re
.
sub
(
r
'
experiment\.
'
,
''
,
name
)
if
'
.
'
in
name
:
segs
=
name
.
split
(
'
.
'
)
name
=
segs
[
1
]
+
'
.
'
+
segs
[
0
]
conv_table
[
'
fields
'
].
append
(
name
)
return
conv_table
def
parse_plot
(
plot
):
conv_plot
=
{
'
name
'
:
plot
[
'
data
'
][
'
output
'
][
0
],
'
type
'
:
plot
[
'
required_plotter
'
][
0
]
}
return
conv_plot
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
)
def
analyzer_fullname
(
report
):
return
'
%s/%s/%s
'
%
(
report
.
analyzer
.
author
.
username
,
report
.
analyzer
.
name
,
report
.
analyzer
.
version
)
def
move_content_to_groups_format
(
apps
,
schema_editor
):
Report
=
apps
.
get_model
(
'
reports
'
,
'
Report
'
)
for
report
in
Report
.
objects
.
all
():
report_content
=
json
.
loads
(
report
.
content
)
# convert to groups format
if
'
groups
'
not
in
report_content
:
exps
=
report
.
experiments
.
all
()
# groups: {
# group1 : {
# experiments: [],
# reportItems: [],
# analyzer: '',
# aliases: {},
# idx: 1
# },
# ...
# }
obj
=
{}
groups
=
{}
group1
=
{
'
experiments
'
:
[
experiment_fullname
(
e
)
for
e
in
exps
],
'
reportItems
'
:
[],
'
analyzer
'
:
analyzer_fullname
(
report
)
if
report
.
analyzer
else
''
,
'
aliases
'
:
{},
'
idx
'
:
1
}
for
e
in
exps
:
group1
[
'
aliases
'
][
experiment_fullname
(
e
)]
=
e
.
name
count_tables
=
0
count_plots
=
0
for
item_name
in
report_content
:
if
item_name
==
'
floating_point_precision
'
or
item_name
==
'
alias_experiments
'
:
continue
item
=
report_content
[
item_name
]
item_type
=
'
table
'
if
item_name
.
startswith
(
'
table
'
)
else
'
plot
'
fpp
=
report_content
[
'
floating_point_precision
'
]
if
'
floating_point_precision
'
in
report_content
else
10
converted_content
=
parse_table
(
item
,
fpp
)
if
item_type
==
'
table
'
else
parse_plot
(
item
)
converted_id
=
''
if
item_type
==
'
table
'
:
converted_id
=
'
table_
'
+
str
(
count_tables
)
count_tables
+=
1
else
:
converted_id
=
'
plot_
'
+
str
(
count_plots
)
count_plots
+=
1
converted_item
=
{
'
id
'
:
converted_id
,
'
content
'
:
converted_content
}
group1
[
'
reportItems
'
].
append
(
converted_item
)
groups
[
'
group1
'
]
=
group1
obj
[
'
groups
'
]
=
groups
report
.
content
=
json
.
dumps
(
obj
)
report
.
save
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
reports
'
,
'
0003_report_last_edited_date
'
),
]
operations
=
[
migrations
.
RunPython
(
move_content_to_groups_format
)
]
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