Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
platy-browser-data
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
Christian Tischer
platy-browser-data
Commits
5b7c9af9
Commit
5b7c9af9
authored
5 years ago
by
Constantin Pape
Browse files
Options
Downloads
Patches
Plain Diff
Update migration scripts
parent
69821226
No related branches found
Branches containing commit
No related tags found
1 merge request
!11
New storage layout
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mmpb/files/migration.py
+15
-8
15 additions, 8 deletions
mmpb/files/migration.py
with
15 additions
and
8 deletions
mmpb/files/migration.py
+
15
−
8
View file @
5b7c9af9
...
...
@@ -5,7 +5,6 @@ from glob import glob
from
mmpb.files.name_lookup
import
(
look_up_filename
,
get_image_properties
,
DYNAMIC_SEGMENTATIONS
,
get_dynamic_segmentation_properties
)
from
mmpb.files.xml_utils
import
get_h5_path_from_xml
,
copy_xml_with_newpath
from
mmpb.files.copy_helper
import
make_squashed_link
ROOT
=
'
/g/arendt/EM_6dpf_segmentation/platy-browser-data/data
'
DRY_RUN
=
True
...
...
@@ -52,6 +51,9 @@ def move_image_file(image_folder, xml_path):
# the new image path might be in rawdata; in this case there is now '/local'
# subfolder, if it is in a version folder, it is in '/local'
im_root
,
im_name
=
os
.
path
.
split
(
image_path
)
# take care of 'segmentations'
if
os
.
path
.
split
(
im_root
)[
1
]
==
'
segmentations
'
:
im_root
=
os
.
path
.
join
(
os
.
path
.
split
(
im_root
)[
0
],
'
images
'
)
new_image_path
=
os
.
path
.
join
(
im_root
,
new_name
+
'
.h5
'
)
if
not
os
.
path
.
exists
(
new_image_path
):
new_image_path
=
os
.
path
.
join
(
im_root
,
'
local
'
,
new_name
+
'
.h5
'
)
...
...
@@ -120,7 +122,10 @@ def update_tables(folder):
continue
# otherwise try to link to the renamed table file
link_folder
,
table_name
=
os
.
path
.
split
(
table_file
)
link_folder
,
table_name
=
os
.
path
.
split
(
link_location
)
# some table names have this typo
if
table_name
==
'
base.csv
'
:
table_name
=
'
default.csv
'
link_folder
=
os
.
path
.
split
(
link_folder
)[
0
]
link_location
=
os
.
path
.
join
(
link_folder
,
new_name
,
table_name
)
assert
os
.
path
.
exists
(
link_location
),
link_location
...
...
@@ -128,7 +133,9 @@ def update_tables(folder):
if
DRY_RUN
:
print
(
"
Moving link from
"
,
table_file
,
link_location
)
else
:
make_squashed_link
(
link_location
,
table_file
,
override
=
True
)
os
.
unlink
(
table_file
)
rel_link
=
os
.
path
.
relpath
(
link_location
,
os
.
path
.
split
(
table_file
)[
0
])
os
.
symlink
(
rel_link
,
table_file
)
def
update_segmentation_data
(
folder
):
...
...
@@ -159,9 +166,6 @@ def update_segmentation_data(folder):
with
open
(
dynamic_seg_path
,
'
w
'
)
as
f
:
json
.
dump
(
dynamic_seg_dict
,
f
,
sort_keys
=
True
,
indent
=
2
)
# update the tables
update_tables
(
folder
)
def
clean_up
(
version_folder
):
# remove segmentation folder (needs to be empty!)
...
...
@@ -194,7 +198,10 @@ def migrate_version(version):
# 3.) iterate over all table links and repair them
update_segmentation_data
(
version_folder
)
# 4.) clean up:
# 4.) update the tables
update_tables
(
version_folder
)
# 5.) clean up:
clean_up
(
version_folder
)
...
...
@@ -307,5 +314,5 @@ if __name__ == '__main__':
# change names and xmls in the rawfolder
# migrate_rawfolder()
version
=
'
0.0.
0
'
version
=
'
0.0.
1
'
migrate_version
(
version
)
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