|
| 1 | +import os |
| 2 | +from SCons.Script import SConscript |
| 3 | +from lsst.sconsUtils.utils import libraryLoaderEnvironment |
| 4 | +from lsst.utils import getPackageDir |
| 5 | +SConscript(os.path.join(".", "bin.src", "SConscript")) |
| 6 | + |
| 7 | +env = Environment(ENV=os.environ) |
| 8 | +env["ENV"]["OMP_NUM_THREADS"] = "1" # Disable threading |
| 9 | + |
| 10 | +location = getPackageDir("ci_hsc_gen3") |
| 11 | + |
| 12 | + |
| 13 | +def getExecutable(package, script, directory=None): |
| 14 | + """ |
| 15 | + Given the name of a package and a script or other executable which lies |
| 16 | + within the given subdirectory (defaults to "bin"), return an appropriate |
| 17 | + string which can be used to set up an appropriate environment and execute |
| 18 | + the command. |
| 19 | + This includes: |
| 20 | + * Specifying an explict list of paths to be searched by the dynamic linker; |
| 21 | + * Specifying a Python executable to be run (we assume the one on the |
| 22 | + default ${PATH} is appropriate); |
| 23 | + * Specifying the complete path to the script. |
| 24 | + """ |
| 25 | + if directory is None: |
| 26 | + directory = "bin" |
| 27 | + return "{} python {}".format(libraryLoaderEnvironment(), |
| 28 | + os.path.join(getPackageDir(package), directory, script)) |
| 29 | + |
| 30 | + |
| 31 | +# Create butler |
| 32 | +butler = env.Command(["butler.yaml", "gen3.sqlite3"], "bin", |
| 33 | + ["{} .".format(getExecutable("daf_butler", "makeButlerRepo.py"))]) |
| 34 | + |
| 35 | +# Use name butler to just run making a butler |
| 36 | +env.Alias("butler", butler) |
| 37 | + |
| 38 | +# Run the linker |
| 39 | +links = env.Command(["CALIB", "raw", "brightObjectMasks", "ps1_pv3_3pi_20170110"], butler, ["bin/linker.sh"]) |
| 40 | + |
| 41 | +register = env.Command("register", links, |
| 42 | + ["{} butler.yaml --nocalibs".format(getExecutable("ci_hsc_gen3", "gen3.py"))]) |
| 43 | + |
| 44 | +sql = env.Command("sql", register, ["bin/dbImport.sh"]) |
| 45 | + |
| 46 | +hsc = env.Command("shared/ci_hsc", sql, ["{} butler.yaml".format(getExecutable("ci_hsc_gen3", "gen3.py"))]) |
| 47 | + |
| 48 | +skymap = env.Command("skymap", hsc, |
| 49 | + ["{} -C configs/skymap.py butler.yaml shared/ci_hsc" |
| 50 | + .format(getExecutable("pipe_tasks", "makeGen3Skymap.py"))]) |
| 51 | + |
| 52 | +externalData = env.Command("external", skymap, |
| 53 | + ["{} butler.yaml".format(getExecutable("ci_hsc_gen3", "ingestExternalData.py"))]) |
| 54 | + |
| 55 | +raws = env.Command("raws", externalData, |
| 56 | + ["{0} butler.yaml {1}/raw -C {1}/configs/ingestRaws.py" |
| 57 | + .format(getExecutable("ci_hsc_gen3", "ingestRaws.py"), location)]) |
| 58 | + |
| 59 | +# Use name ingest to run everything up to but not including running the |
| 60 | +# pipeline |
| 61 | +env.Alias("ingest", raws) |
| 62 | + |
| 63 | +num_process = GetOption('num_jobs') |
| 64 | + |
| 65 | +pipeline = env.Command("shared/ci_hsc_output", raws, ["bin/pipeline.sh {}".format(num_process)]) |
| 66 | + |
| 67 | +everything = [butler, links, register, sql, hsc, skymap, externalData, raws, pipeline] |
| 68 | + |
| 69 | +env.Alias("all", everything) |
| 70 | +Default(everything) |
| 71 | + |
| 72 | +env.Clean(everything, [y for x in everything for y in x]) |
0 commit comments