# Train the energy, gammaness, and disp reconstruction models.
#
# Run inside the pixi environment (e.g. `pixi shell -e test`), or override
# CWLTOOL/PYTHON, e.g. `make CWLTOOL="pixi run -e test cwltool"`.

CWLTOOL ?= cwltool
PYTHON ?= python
CWLFLAGS ?= --no-container --parallel

WORKFLOW = workflow_train_models.cwl
INPUTS = train_models_input.json
# cwltool output object, listing the files produced by the workflow
OUTPUTS = train_models_output.json

.PHONY: all inputs clean

all: $(OUTPUTS)

inputs: $(INPUTS)

$(INPUTS): generate_inputs.py
	$(PYTHON) generate_inputs.py

$(OUTPUTS): $(WORKFLOW) $(INPUTS) training_config.yaml
	$(CWLTOOL) $(CWLFLAGS) --outdir=. --write-summary=$@.tmp $(WORKFLOW) $(INPUTS)
	mv $@.tmp $@

clean:
	rm -f *.recomodel.zip *.provenance.log $(INPUTS) $(OUTPUTS) $(OUTPUTS).tmp
