Skip to content

Commit

Permalink
better use of PYTHONPATH
Browse files Browse the repository at this point in the history
  • Loading branch information
jadball committed Aug 1, 2024
1 parent 23c6a3a commit 6f3d38f
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 42 deletions.
8 changes: 2 additions & 6 deletions ImageD11/nbGui/S3DXRD/run_astra_recon.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ def main(h5name, dsfile):
# horrible workaround to include id11 code path
import sys

id11_code_path = sys.argv[1]

sys.path.insert(0, id11_code_path)

from ImageD11.sinograms.sinogram import read_h5, write_h5
import ImageD11.sinograms.dataset
import numpy as np

h5name = sys.argv[2]
dsfile = sys.argv[3]
h5name = sys.argv[1]
dsfile = sys.argv[2]

main(h5name, dsfile)
16 changes: 6 additions & 10 deletions ImageD11/nbGui/S3DXRD/run_mlem_recon.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ def main(h5name, ginc, dsfile, dest, nthreads):

if __name__ == "__main__":
# horrible workaround to include id11 code path
import sys

id11_code_path = sys.argv[1]

sys.path.insert(0, id11_code_path)
import sys

import numpy as np
import h5py
Expand All @@ -41,10 +37,10 @@ def main(h5name, ginc, dsfile, dest, nthreads):
from ImageD11.sinograms.sinogram import GrainSinogram
import ImageD11.grain

h5name = sys.argv[2]
ginc = int(sys.argv[3])
dsfile = sys.argv[4]
dest = sys.argv[5]
nthreads = int(sys.argv[6])
h5name = sys.argv[1]
ginc = int(sys.argv[2])
dsfile = sys.argv[3]
dest = sys.argv[4]
nthreads = int(sys.argv[5])

main(h5name, ginc, dsfile, dest, nthreads)
35 changes: 15 additions & 20 deletions ImageD11/nbGui/S3DXRD/run_pbp_recon.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
if __name__ == "__main__":
# horrible workaround to include id11 code path
import sys

id11_code_path = sys.argv[1]

sys.path.insert(0, id11_code_path)

import sys
import ImageD11.sinograms.point_by_point
import ImageD11.sinograms.dataset
from ImageD11 import cImageD11
import ast

dsfile = sys.argv[2]
hkltol = float(sys.argv[3])
fpks = float(sys.argv[4])
dstol = float(sys.argv[5])
etacut = float(sys.argv[6])
ifrac = float(sys.argv[7])
costol = float(sys.argv[8])
y0 = float(sys.argv[9])
symmetry = sys.argv[10]
foridx = [int(x) for x in ast.literal_eval(sys.argv[11])]
forgen = [int(x) for x in ast.literal_eval(sys.argv[12])]
uniqcut = float(sys.argv[13])
minpkint = int(sys.argv[14])
dsfile = sys.argv[1]
hkltol = float(sys.argv[2])
fpks = float(sys.argv[3])
dstol = float(sys.argv[4])
etacut = float(sys.argv[5])
ifrac = float(sys.argv[6])
costol = float(sys.argv[7])
y0 = float(sys.argv[8])
symmetry = sys.argv[9]
foridx = [int(x) for x in ast.literal_eval(sys.argv[10])]
forgen = [int(x) for x in ast.literal_eval(sys.argv[11])]
uniqcut = float(sys.argv[12])
minpkint = int(sys.argv[13])

print('Loading dset')
ds = ImageD11.sinograms.dataset.load(dsfile)
Expand Down Expand Up @@ -52,4 +47,4 @@
pbp_object.setpeaks(cf_2d)

print('Go for pbp')
pbp_object.point_by_point(ds.pbpfile, loglevel=3)
pbp_object.point_by_point(ds.pbpfile, loglevel=3)
12 changes: 6 additions & 6 deletions ImageD11/nbGui/nb_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def prepare_mlem_bash(ds, grains, id11_code_path, n_simultaneous_jobs=50, cores_
#SBATCH --cpus-per-task={cores_per_task}
#
date
echo python3 {python_script_path} {id11_code_path} {grainsfile} $SLURM_ARRAY_TASK_ID {dsfile} {reconfile} {cores_per_task} > {log_path} 2>&1
python3 {python_script_path} {id11_code_path} {grainsfile} $SLURM_ARRAY_TASK_ID {dsfile} {reconfile} {cores_per_task} > {log_path} 2>&1
echo PYTHONPATH={id11_code_path} python3 {python_script_path} {grainsfile} $SLURM_ARRAY_TASK_ID {dsfile} {reconfile} {cores_per_task} > {log_path} 2>&1
PYTHONPATH={id11_code_path} python3 {python_script_path} {grainsfile} $SLURM_ARRAY_TASK_ID {dsfile} {reconfile} {cores_per_task} > {log_path} 2>&1
date
""".format(outfile_path=outfile_path,
errfile_path=errfile_path,
Expand Down Expand Up @@ -198,8 +198,8 @@ def prepare_astra_bash(ds, grainsfile, id11_code_path):
#
date
module load cuda
echo python3 {python_script_path} {id11_code_path} {grainsfile} {dsfile} > {log_path} 2>&1
python3 {python_script_path} {id11_code_path} {grainsfile} {dsfile} > {log_path} 2>&1
echo PYTHONPATH={id11_code_path} python3 {python_script_path} {grainsfile} {dsfile} > {log_path} 2>&1
PYTHONPATH={id11_code_path} python3 {python_script_path} {grainsfile} {dsfile} > {log_path} 2>&1
date
""".format(outfile_path=outfile_path,
errfile_path=errfile_path,
Expand Down Expand Up @@ -243,8 +243,8 @@ def prepare_pbp_bash(pbp_object, id11_code_path, minpkint):
#
date
source /cvmfs/hpc.esrf.fr/software/packages/linux/x86_64/jupyter-slurm/latest/envs/jupyter-slurm/bin/activate
echo python3 {python_script_path} {id11_code_path} {dsfile} {hkltol} {fpks} {dstol} {etacut} {ifrac} {costol} {y0} {symmetry} {foridx} {forgen} {uniqcut} {minpkint} > {log_path} 2>&1
OMP_NUM_THREADS=1 python3 {python_script_path} {id11_code_path} {dsfile} {hkltol} {fpks} {dstol} {etacut} {ifrac} {costol} {y0} {symmetry} {foridx} {forgen} {uniqcut} {minpkint} > {log_path} 2>&1
echo OMP_NUM_THREADS=1 PYTHONPATH={id11_code_path} python3 {python_script_path} {dsfile} {hkltol} {fpks} {dstol} {etacut} {ifrac} {costol} {y0} {symmetry} {foridx} {forgen} {uniqcut} {minpkint} > {log_path} 2>&1
OMP_NUM_THREADS=1 PYTHONPATH={id11_code_path} python3 {python_script_path} {dsfile} {hkltol} {fpks} {dstol} {etacut} {ifrac} {costol} {y0} {symmetry} {foridx} {forgen} {uniqcut} {minpkint} > {log_path} 2>&1
date
""".format(outfile_path=outfile_path,
errfile_path=errfile_path,
Expand Down

0 comments on commit 6f3d38f

Please sign in to comment.