@@ -97,23 +97,25 @@ function element_not_in_array() {
9797 return $found
9898}
9999
100- usage=" ${0##*/ } [-h|--help] [--exit-when-done] [--offline] [--enable-coverage] [--no-mount-containerd] [--set-value key=value] [--ci-values=values.yaml] [--] [source directories]"
100+ usage=" ${0##*/ } [-h|--help] [--exit-when-done] [--offline] [--enable-coverage] [--no-mount-containerd] [--set-value key=value] [--ci-values=values.yaml] [--load-docker-image=<image_name:tag>] [-- ] [source directories]"
101101usage+=" \n\n"
102102usage+=" -h|--help: Print this help message and exit\n"
103+ usage+=" --ci-values: Path to a values.yaml file which contains diracx dev settings only enabled for CI\n"
103104usage+=" --exit-when-done: Exit after the demo has been started (it will be left running in the background)\n"
104105usage+=" --enable-coverage: Enable coverage reporting (used by diracx CI)\n"
106+ usage+=" --enable-open-telemetry: lauches OpenTelemetry collection.\n"
107+ usage+=" WARNING: experimental and resource hungry.\n"
108+ usage+=" --load-docker-image: Mount a local docker image into kind\n"
109+ usage+=" WARNING: the ImagePullPolicy MUST not be Always for this to work\n"
105110usage+=" --no-editable-python: Do not install Python source directories in editable mode\n"
106- usage+=" --offline: Run in a mode which is suitable for fully offline use.\n"
107- usage+=" WARNING: This may result in some weird behaviour, see the demo documentation for details.\n"
108- usage+=" Implies: --mount-containerd\n"
109111usage+=" --no-mount-containerd: Mount a directory on the host for the kind containerd storage.\n"
110112usage+=" This option avoids needing to pull container images every time the demo is started.\n"
111113usage+=" WARNING: There is no garbage collection so the directory will grow without bound.\n"
112- usage+=" --enable-open-telemetry: lauches OpenTelemetry collection.\n"
113- usage+=" WARNING: experimental and resource hungry.\n"
114+ usage+=" --offline: Run in a mode which is suitable for fully offline use.\n"
115+ usage+=" WARNING: This may result in some weird behaviour, see the demo documentation for details.\n"
116+ usage+=" Implies: --mount-containerd\n"
114117usage+=" --set-value: Set a value in the Helm values file. This can be used to override the default values.\n"
115118usage+=" For example, to enable coverage reporting pass: --set-value developer.enableCoverage=true\n"
116- usage+=" --ci-values: Path to a values.yaml file which contains diracx dev settings only enabled for CI\n"
117119usage+=" source directories: A list of directories containing Python packages to mount in the demo cluster.\n"
118120
119121# Parse command-line switches
@@ -124,7 +126,8 @@ declare -a helm_arguments=()
124126enable_coverage=0
125127editable_python=1
126128open_telemetry=0
127- ci_values_file=" "
129+ declare -a ci_values_files=()
130+ declare -a docker_images_to_load=()
128131
129132while [ -n " ${1:- } " ]; do case $1 in
130133 # Print a brief usage summary and exit
@@ -197,6 +200,16 @@ while [ -n "${1:-}" ]; do case $1 in
197200 shift
198201 continue ;;
199202
203+ --load-docker-image)
204+ shift
205+ if [[ -z " ${1:- } " ]]; then
206+ printf " %b Error: --load-docker-image requires an argument\n" ${SKULL_EMOJI}
207+ exit 1
208+ fi
209+ docker_images_to_load+=(" ${1} " )
210+ shift
211+ continue ;;
212+
200213 --ci-values)
201214 shift
202215 if [[ -z " ${1:- } " ]]; then
@@ -208,6 +221,7 @@ while [ -n "${1:-}" ]; do case $1 in
208221 printf " %b Error: --ci-values does not point to a file\n" ${SKULL_EMOJI}
209222 exit 1;
210223 fi
224+ ci_values_files+=(" ${ci_values_file} " )
211225 shift
212226 continue ;;
213227
234248declare -a pkg_dirs=()
235249declare -a python_pkg_names=()
236250node_pkg_name=" "
237- diracx_src_dir= " "
251+ declare -a diracx_and_extensions_pkgs=()
238252
239253for src_dir in " $@ " ; do
240254 if [ ${# pkg_dirs[@]} -gt 0 ] && ! element_not_in_array " $src_dir " " ${pkg_dirs[@]} " ; then
@@ -243,18 +257,30 @@ for src_dir in "$@"; do
243257 fi
244258 pkg_dirs+=(" ${src_dir} " )
245259
246- # DiracX itself
260+
261+ # Does that look like a namespace package with the structure we expect ?
262+ # i.e. is it diracx itself or an extension ?
247263 if [ -f " ${src_dir} /pyproject.toml" ]; then
248- if grep --quiet ' name = "diracx"' " ${src_dir} /pyproject.toml" ; then
249- if [ " ${diracx_src_dir} " != " " ]; then
250- printf " %b Error: Source directory for DiracX was given twice!\n" " ${SKULL_EMOJI} "
251- exit 1
264+ # Name of the package
265+ pkg_name=" $( basename " ${src_dir} " ) "
266+
267+ # Do we find subdirectories called the same way as the package
268+ if [ -n " $( find " ${src_dir} " -mindepth 3 -maxdepth 3 -type d -path " *src/${pkg_name} " ) " ]; then
269+ # And are there mulftiple pyprojects
270+ if [ -n " $( find " ${src_dir} " -mindepth 2 -maxdepth 2 -type f -name " pyproject.toml" ) " ]; then
271+ # Then let's add all these
272+ while IFS= read -r sub_pkg_dir
273+ do
274+ diracx_and_extensions_pkgs+=(" $( basename " ${src_dir} " ) /$( basename " ${sub_pkg_dir} " ) " );
275+ done < <( find " ${src_dir} " -mindepth 1 -maxdepth 1 -type d -name " ${pkg_name} -*" )
276+
277+ continue ;
278+ fi ;
252279 fi
253- diracx_src_dir=" ${src_dir} "
254- continue
255- fi
280+
256281 fi
257282
283+
258284 # Python packages
259285 if [ -f " ${src_dir} /pyproject.toml" ]; then
260286 while IFS=' ' read -r pkg_dir; do
@@ -279,8 +305,9 @@ for src_dir in "$@"; do
279305 done < <( find " $src_dir " -mindepth 1 -maxdepth 1 -type f -name ' package.json' )
280306done
281307
282- if [ " ${diracx_src_dir} " != " " ]; then
283- printf " %b Found DiracX directory: %s\n" ${UNICORN_EMOJI} " ${diracx_src_dir} "
308+
309+ if [ ${# diracx_and_extensions_pkgs[@]} -gt 0 ]; then
310+ printf " %b Found Diracx/Extensions package directories for: %s\n" ${UNICORN_EMOJI} " ${diracx_and_extensions_pkgs[*]} "
284311fi
285312if [ ${# python_pkg_names[@]} -gt 0 ]; then
286313 printf " %b Found Python package directories for: %s\n" ${UNICORN_EMOJI} " ${python_pkg_names[*]} "
@@ -452,11 +479,12 @@ if [ ${#python_pkg_names[@]} -gt 0 ]; then
452479 json+=" \" $pkg_name \" ,"
453480 done
454481fi
455- if [ " ${diracx_src_dir} " != " " ]; then
456- for pkg_name in " $( basename " ${diracx_src_dir} " ) /diracx-" {cli,client,api,core,routers,db}; do
457- json+=" \" $pkg_name \" ,"
458- done
459- fi
482+
483+ for diracx_compatible_pkg in " ${diracx_and_extensions_pkgs[@]} " ; do
484+ json+=" \" $diracx_compatible_pkg \" ,"
485+
486+ done
487+
460488json=" ${json% ,} ]"
461489sed " s#{{ mounted_python_modules }}#${json} #g" " ${demo_dir} /values.yaml.bak" > " ${demo_dir} /values.yaml"
462490mv " ${demo_dir} /values.yaml" " ${demo_dir} /values.yaml.bak"
@@ -470,6 +498,7 @@ if grep '{{' "${demo_dir}/values.yaml"; then
470498 exit 1
471499fi
472500
501+
473502# Add an ingress to the cluster
474503printf " %b Creating an ingress...\n" ${UNICORN_EMOJI}
475504# TODO: This should move to the chart itself
@@ -487,9 +516,30 @@ printf "%b Waiting for ingress controller to be created...\n" ${UNICORN_EMOJI}
487516# Install the DiracX chart
488517printf " %b Installing DiracX...\n" ${UNICORN_EMOJI}
489518helm_arguments+=(" --values" " ${demo_dir} /values.yaml" )
490- if [[ -n " ${ci_values_file} " ]]; then
491- helm_arguments+=(" --values" " ${ci_values_file} " )
519+
520+ if [ ${# ci_values_files[@]} -ne 0 ]; then
521+ printf " %b Adding extra values.yaml: ${ci_values_files[*]} \n" ${UNICORN_EMOJI}
522+ for ci_values_file in " ${ci_values_files[@]} "
523+ do
524+ helm_arguments+=(" --values" " ${ci_values_file} " )
525+ done
492526fi
527+
528+
529+ # Load images into kind
530+
531+ if [ ${# docker_images_to_load[@]} -ne 0 ]; then
532+ printf " %b Loading docker images...\n" ${UNICORN_EMOJI}
533+ for img_name in " ${docker_images_to_load[@]} "
534+ do
535+ " ${demo_dir} /kind" --name diracx-demo load docker-image " ${img_name} "
536+ done
537+
538+
539+ fi ;
540+
541+
542+
493543if ! " ${demo_dir} /helm" install --debug diracx-demo " ${script_dir} /diracx" " ${helm_arguments[@]} " ; then
494544 printf " %b Error using helm DiracX\n" ${WARN_EMOJI}
495545 echo " Failed to run \" helm install\" " >> " ${demo_dir} /.failed"
0 commit comments