Skip to content

Commit

Permalink
Solved issue 56. #56
Browse files Browse the repository at this point in the history
  • Loading branch information
luissian committed Jan 24, 2022
1 parent e4a8801 commit c0da811
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 87 deletions.
2 changes: 1 addition & 1 deletion iSkyLIMS_core/templates/iSkyLIMS_core/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h4>Powered by :</h4>
</div>
<div class="row">
<div class="col-md-2 col-md-offset-5">
<p>Version 2.0.1</p>
<p>Version 2.0.2</p>
</div>
</div>
<!--// end row -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def run ():
'''
The script migration is needed to copy the sequencer information from the table in
drylab to core.
The csv file contains "run_id, sequencer_name"
'''

run_objs = RunProcess.objects.all()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
This file is part of the migration preparation for the version 2.0.0.
It collect the information for the projects table for having the
functionality that Project name can be repeated in different runs
The csv file contains "project_id, run_id"
'''
def run ():

Expand All @@ -13,7 +14,7 @@ def run ():
print('There is no projects defined in iSkyLIMS\n')
print('No upload project script is required to execute')
return
with open ('project_migration_data.csv', 'w') as fh:
with open ('part_1_projectID_runID_migration.csv', 'w') as fh:
for project in projects_to_update :
fh.write(str(project.pk) + ',' + str(project.runprocess_id.pk) + '\n')

Expand Down
11 changes: 7 additions & 4 deletions iSkyLIMS_wetlab/scripts/prepare_part2_project_mig_many2many.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
This file is part of the migration preparation for the version 2.0.0.
It collect the information for the sampleInProject table for having
the functionality that Project name can be repeated in different runs
Two csv files are generated:
- part2_Samples_linked_to_Runs_migration_data.csv having smaple_id, run_id
- part2_Samples_linked_to_Users_migration_data.csv having sample_id, user_id
'''

def run ():
Expand All @@ -13,13 +16,13 @@ def run ():
print('There is no SamplesInProjects defined in iSkyLIMS\n')
print('No upload SamplesInProject script is required to execute')
return
with open ('part1_sampleInProject_migration_data.csv', 'w') as fh:
with open ('part2_SamplesID_RunsID_migration.csv', 'w') as fh:
for sample in samples_to_update :
project_obj = sample.project_id
run_objs = project_obj.runProcess.all()
fh.write(str(sample.pk) + ',' + str(run_objs[0].pk) + '\n')
run_obj = project_obj.runprocess_id
fh.write(str(sample.pk) + ',' + str(run_obj.pk) + '\n')

with open ('part2_sampleInProject_migration_data.csv', 'w') as fh:
with open ('part2_SamplesID_UsersID_migration.csv', 'w') as fh:
for sample in samples_to_update :
project_obj = sample.project_id
user_id = project_obj.user_id.pk
Expand Down
47 changes: 0 additions & 47 deletions iSkyLIMS_wetlab/scripts/prepare_part3_project_mig_many2many.py

This file was deleted.

5 changes: 5 additions & 0 deletions iSkyLIMS_wetlab/scripts/update_part0_machines_migration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from iSkyLIMS_wetlab.models import RunProcess
from iSkyLIMS_core.models import SequencerInLab

'''
The script migration restore the information collected in the prepare_part0_machines_migration .
Fetching the run_id and the sequencer name.
The csv file contains "run_id, sequencer_name"
'''

def get_list_defined_sequencers ():
if SequencerInLab.objects.all().exists():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
from iSkyLIMS_wetlab.models import SamplesInProject, RunProcess, Projects
from django.contrib.auth.models import User

'''
The script migration restore the information collected in the prepare_part1_project_for_migration_to_many_to_many .
Fetching the run_id and the sequencer name.
The csv file contains "project_id ,run_id"
'''

def run ():
invalids = 0

with open ('project_migration_data.csv', 'r') as fh:
with open ('part_1_projectID_runID_migration.csv', 'r') as fh:
for line in fh.readlines():
split_line = line.split(',')
if len(split_line )!= 2:
Expand Down
34 changes: 2 additions & 32 deletions iSkyLIMS_wetlab/scripts/update_part2_project_mig_many2many.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def run ():

invalids = 0

with open ('part1_sampleInProject_migration_data.csv', 'r') as fh:
with open ('part2_SamplesID_RunsID_migration.csv', 'r') as fh:
for line in fh.readlines():
split_line = line.split(',')
if len(split_line )!= 2:
Expand All @@ -28,37 +28,7 @@ def run ():
s_obj.runProcess_id = (r_obj)
s_obj.save()

with open ('part1.1_sampleInProject_migration_data.csv', 'r') as fh:
for line in fh.readlines():
split_line = line.split(',')
if len(split_line )!= 2:
print('invalid line :' , line , '\n')
continue
s_id = split_line[0]
p_id = split_line[1]
if SamplesInProject.objects.filter(pk__exact = s_id).exists():
s_obj = SamplesInProject.objects.get(pk__exact = s_id)
else:
print('sample in project id ' , s_id , 'does not longer exists in database\n')
invalids += 1
continue
if Projects.objects.filter(pk__exact = r_id).exists():
p_obj = Projects.objects.get(pk__exact = p_id)
else:
print('Project id ' , p_id, 'does not longer exists in database\n')
invalids += 1
continue
s_obj.project_id = (p_obj)
s_obj.save()

if invalids == 0:
print( 'All samples have been updated to get relation with run\n')
else:
print('Unable to migrate all Samples to have runProcess relation ')

invalids = 0

with open ('part2_sampleInProject_migration_data.csv', 'r') as fh:
with open ('part2_SamplesID_UsersID_migration.csv', 'r') as fh:
for line in fh.readlines():
split_line = line.split(',')
if len(split_line )!= 2:
Expand Down

0 comments on commit c0da811

Please sign in to comment.