Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
imageflow-repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Model registry
Operate
Environments
Terraform modules
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
chaskar2
imageflow-repo
Commits
e12997f5
Commit
e12997f5
authored
7 months ago
by
chaskar2
Browse files
Options
Downloads
Patches
Plain Diff
added default value for base_path
parent
61318e11
Branches
assignment1.2
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dags/imageflow_dag.py
+19
-19
19 additions, 19 deletions
dags/imageflow_dag.py
with
19 additions
and
19 deletions
dags/imageflow_dag.py
+
19
−
19
View file @
e12997f5
...
...
@@ -213,8 +213,8 @@ def imageflow_dag(**dag_input):
# Create the base path directory if it doesn't exist
if
not
os
.
path
.
exists
(
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
"
):
os
.
mkdir
(
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
"
)
if
not
os
.
path
.
exists
(
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
"
):
os
.
mkdir
(
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
"
)
# Load the scan configuration from the file
with
open
(
"
/scan_params/scan_config.json
"
,
"
r
"
)
as
conf
:
...
...
@@ -227,8 +227,8 @@ def imageflow_dag(**dag_input):
curr_conf_dict
=
prepare_current_scan_config
(
scan_config
,
tumor_activity_choice
)
# Save the current scan configuration to a file
with
open
(
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/curr_scan_config.json
"
,
"
w+
"
)
as
curr_conf
:
print
(
f
"
Directory scan params written to:
{
Variable
.
get
(
'
base_
path
'
)
}
"
)
with
open
(
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/curr_scan_config.json
"
,
"
w+
"
)
as
curr_conf
:
print
(
f
"
Directory scan params written to:
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
"
)
json
.
dump
(
curr_conf_dict
,
curr_conf
)
return
0
...
...
@@ -241,9 +241,9 @@ def imageflow_dag(**dag_input):
# TODO: Copy all macros file data files
shutil
.
copytree
(
'
/gate_output/NCSA_RubInWater/Macros
'
,
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/Macros
"
)
shutil
.
copytree
(
'
/gate_output/NCSA_RubInWater/Data
'
,
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/Data
"
)
shutil
.
copy
(
'
/gate_output/NCSA_RubInWater/main.mac
'
,
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/main.mac
"
)
shutil
.
copytree
(
'
/gate_output/NCSA_RubInWater/Macros
'
,
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/Macros
"
)
shutil
.
copytree
(
'
/gate_output/NCSA_RubInWater/Data
'
,
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/Data
"
)
shutil
.
copy
(
'
/gate_output/NCSA_RubInWater/main.mac
'
,
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/main.mac
"
)
return
0
...
...
@@ -259,20 +259,20 @@ def imageflow_dag(**dag_input):
# TODO: Replace the macros with user selected values
# Open the current scan configuration file
with
open
(
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/curr_scan_config.json
"
,
"
r+
"
)
as
curr_conf
:
with
open
(
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/curr_scan_config.json
"
,
"
r+
"
)
as
curr_conf
:
curr_conf
=
json
.
load
(
curr_conf
)
# Set the activity file property for the GATE simulation software
activity_file_property
=
"
/gate/source/voxel_blob/imageReader/rangeTranslator/readTable
"
activity_file_value
=
curr_conf
[
"
activity_file
"
]
set_macro_property
(
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/Macros/VoxelizedSource.mac
"
,
activity_file_property
,
activity_file_value
,
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/Macros/VoxelizedSource.mac
"
)
set_macro_property
(
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/Macros/VoxelizedSource.mac
"
,
activity_file_property
,
activity_file_value
,
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/Macros/VoxelizedSource.mac
"
)
main_mac_file
=
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/main.mac
"
main_mac_file
=
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/main.mac
"
for
component
in
range
(
20
):
# Set the output file property for the GATE simulation software
new_mac_file
=
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/main_
{
component
}
.mac
"
new_mac_file
=
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/main_
{
component
}
.mac
"
output_mac_file_property
=
"
/control/execute
"
original_output_file_value
=
"
Macros/Output.mac
"
...
...
@@ -281,12 +281,12 @@ def imageflow_dag(**dag_input):
output_file_property
=
"
/gate/output/root/setFileName
"
output_file_value
=
f
"
Output/output_
{
component
}
.root
"
set_macro_property
(
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/Macros/Output.mac
"
,
output_file_property
,
output_file_value
,
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/Macros/Output_
{
component
}
.mac
"
)
set_macro_property
(
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/Macros/Output.mac
"
,
output_file_property
,
output_file_value
,
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/Macros/Output_
{
component
}
.mac
"
)
# Create the Output directory if it doesn't exist
if
not
os
.
path
.
exists
(
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/Output
"
):
os
.
makedirs
(
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/Output
"
)
if
not
os
.
path
.
exists
(
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/Output
"
):
os
.
makedirs
(
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/Output
"
)
return
0
...
...
@@ -305,10 +305,10 @@ def imageflow_dag(**dag_input):
print
(
f
"
Folder does not exist:
{
Variable
.
get
(
'
base_output_path
'
,
'
placeholder
'
)
}
"
)
# Move the output files from the pipeline to the output directory
shutil
.
copytree
(
Variable
.
get
(
'
base_
path
'
),
Variable
.
get
(
'
base_output_path
'
,
'
placeholder
'
))
shutil
.
copytree
(
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
),
Variable
.
get
(
'
base_output_path
'
,
'
placeholder
'
))
# Remove the pipeline output directory
shutil
.
rmtree
(
Variable
.
get
(
'
base_
path
'
))
shutil
.
rmtree
(
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
))
# Copy the castor reconstruction script to the output directory
shutil
.
copy
(
"
/castor_files/castor_reconstruction.sh
"
,
Variable
.
get
(
'
base_output_path
'
,
'
placeholder
'
))
...
...
@@ -338,7 +338,7 @@ def imageflow_dag(**dag_input):
get_image_statistics: Get layer wise mean values for the volume
"""
# Remove the output.root file from the base path
os
.
remove
(
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
/Output/output.root.root
"
)
os
.
remove
(
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
/Output/output.root.root
"
)
img_mean_stats
=
[]
...
...
@@ -384,7 +384,7 @@ def imageflow_dag(**dag_input):
img_mean_stats
,
img_sd_stats
=
get_image_statistics
(
stack_of_images
)
with
open
(
'
/castor_files/stats_output/img_statistics.csv
'
,
'
a
'
)
as
fd
:
fd
.
write
(
f
"
{
Variable
.
get
(
'
base_
path
'
)
}
,
{
img_mean_stats
}
,
{
img_sd_stats
}
\n
"
)
fd
.
write
(
f
"
{
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
)
}
,
{
img_mean_stats
}
,
{
img_sd_stats
}
\n
"
)
print
(
"
Statistics written to file
"
)
return
0
...
...
@@ -429,7 +429,7 @@ def imageflow_dag(**dag_input):
volumes
=
[
gate_volume
,
gate_output_volume
,
gate_scan_params_volume
,
gate_output_pipeline_volume
],
volume_mounts
=
[
gate_volume_mount
,
gate_output_volume_mount
,
gate_scan_params_volume_mount
,
gate_output_pipeline_volume_mount
],
cmds
=
[
"
/gate_files/gate_runner/runGate.sh
"
],
arguments
=
[
Variable
.
get
(
'
base_
path
'
),
f
"
main_
{
i
}
.mac
"
],
arguments
=
[
Variable
.
get
(
'
base_
output_path
'
,
'
placeholder
'
),
f
"
main_
{
i
}
.mac
"
],
execution_timeout
=
timedelta
(
minutes
=
30
),
get_logs
=
True
,
affinity
=
{
...
...
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