Start implementing new way to build command line arguments and defaults based on options classes directly

This commit is contained in:
2025-09-03 12:47:39 +02:00
parent d1e075cca4
commit 319cbb4c2c
3 changed files with 16 additions and 21 deletions
+13 -20
View File
@@ -150,9 +150,7 @@ class ArgParsable:
# optional argument
typ = get_args(field.type)[0]
import inspect
print('typ', inspect.isclass(typ))
if issubclass(typ, StrEnum):
if isinstance(typ, type) and issubclass(typ, StrEnum):
# convert str to enum
try:
value = typ(value)
@@ -460,23 +458,18 @@ class EOSConfig:
if self.output.outputFormats != ['Rqz.ort']:
otpt += f' -of {" ".join(self.output.outputFormats)}'
mask = ''
if self.experiment.yRange != Defaults.yRange:
mask += f' -y {" ".join(str(ii) for ii in self.experiment.yRange)}'
if self.experiment.lambdaRange!= Defaults.lambdaRange:
mask += f' -l {" ".join(str(ff) for ff in self.experiment.lambdaRange)}'
if self.reduction.thetaRange != Defaults.thetaRange:
mask += f' -t {" ".join(str(ff) for ff in self.reduction.thetaRange)}'
elif self.reduction.thetaRangeR != Defaults.thetaRangeR:
mask += f' -T {" ".join(str(ff) for ff in self.reduction.thetaRangeR)}'
if self.experiment.qzRange!= Defaults.qzRange:
mask += f' -q {" ".join(str(ff) for ff in self.experiment.qzRange)}'
mask = ''
# TODO: Check if you want these parameters for the case of default call
mask += f' -y {" ".join(str(ii) for ii in self.experiment.yRange)}'
mask += f' -l {" ".join(str(ff) for ff in self.experiment.lambdaRange)}'
mask += f' -t {" ".join(str(ff) for ff in self.reduction.thetaRange)}'
mask += f' -T {" ".join(str(ff) for ff in self.reduction.thetaRangeR)}'
mask += f' -q {" ".join(str(ff) for ff in self.reduction.qzRange)}'
para = ''
if self.experiment.chopperPhase != Defaults.chopperPhase:
para += f' --chopperPhase {self.experiment.chopperPhase}'
if self.experiment.chopperPhaseOffset != Defaults.chopperPhaseOffset:
para += f' --chopperPhaseOffset {self.experiment.chopperPhaseOffset}'
# TODO: Check if we want these parameters for defaults
para += f' --chopperPhase {self.experiment.chopperPhase}'
para += f' --chopperPhaseOffset {self.experiment.chopperPhaseOffset}'
if self.experiment.mu:
para += f' --mu {self.experiment.mu}'
elif self.experiment.muOffset:
@@ -491,8 +484,8 @@ class EOSConfig:
acts = ''
if self.reduction.autoscale:
acts += f' --autoscale {" ".join(str(ff) for ff in self.reduction.autoscale)}'
if self.reduction.scale != Defaults.scale:
acts += f' --scale {self.reduction.scale}'
# TODO: Check if should be shown if not default
acts += f' --scale {self.reduction.scale}'
if self.reduction.timeSlize:
acts += f' --timeSlize {" ".join(str(ff) for ff in self.reduction.timeSlize)}'
+3 -1
View File
@@ -17,7 +17,9 @@ class AmorReduction:
self.reader_config = config.reader
self.reduction_config = config.reduction
self.output_config = config.output
self.grid = Grid(config.reduction.qResolution, config.experiment.qzRange)
# TODO: bad work-around, should make better destriction of parameters usage
self.experiment_config.qzRange = self.reduction_config.qzRange
self.grid = Grid(config.reduction.qResolution, config.reduction.qzRange)
self.header = Header()
self.header.reduction.call = config.call_string()
Binary file not shown.