Skip to content

Commit

Permalink
Merge pull request #344 from caracal-pipeline/issue-122
Browse files Browse the repository at this point in the history
Issue 121+122
  • Loading branch information
o-smirnov authored Nov 7, 2024
2 parents 7b908b0 + 34a6fe5 commit 3615866
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
18 changes: 12 additions & 6 deletions stimela/backends/flavours/casa.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ class CasaTaskFlavour(_CallableFlavour):
kind: str = "casa-task"
path: Optional[str] = None # path to CASA executable
opts: Optional[List[str]] = EmptyListDefault() # additional options
wrapper: Optional[str] = None # wrapper command (e.g. xvfb-run -a)

def finalize(self, cab: Cab):
super().finalize(cab)

err_patt = re.compile("(?P<content>(\tSEVERE\t|ABORTING|\*\*\* Error \*\*\*)(.*))$")
# catch CASA error messages, except the MeasTable::dUTC complaints which are all-pervasive
err_patt = re.compile("(?P<content>(\tSEVERE\s+(?!MeasTable::dUTC)|ABORTING|\*\*\* Error \*\*\*)(.*))$")
cab._wranglers.append((
err_patt, [
wranglers.DeclareError(err_patt, "ERROR", message="CASA error: {content}" )
Expand Down Expand Up @@ -59,10 +61,14 @@ def get_arguments(self, cab: Cab, params: Dict[str, Any], subst: Dict[str, Any],
casa_opts = [context.evaluate(opt, location=["opts"]) for opt in casa_opts]
except Exception as exc:
raise SubstitutionError(f"error substituting casa options '{casa_opts}'", exc)

# check for virtual_env
if virtual_env and "/" not in command:
command = f"{virtual_env}/bin/{command}"
wrapper = self.wrapper if self.wrapper is not None else casa_config.get('wrapper', 'xvfb-run -a')
if wrapper:
try:
wrapper = [context.evaluate(wrapper, location=["wrapper"])]
except Exception as exc:
raise SubstitutionError(f"error substituting wrapper '{wrapper}'", exc)
else:
wrapper = []

self.command_name = command
pass_params = dict(cab.filter_input_params(params))
Expand All @@ -72,7 +78,7 @@ def get_arguments(self, cab: Cab, params: Dict[str, Any], subst: Dict[str, Any],
# this works for both python 2.7 and 3.x
code = f"{command}(**{pass_params})"

args = casa.strip().split() + list(casa_opts) + ["-c", code]
args = wrapper + casa.strip().split() + list(casa_opts) + ["-c", code]
return args


Expand Down
1 change: 1 addition & 0 deletions stimela/stimela.conf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ opts:
casa:
path: casa
opts: [--log2term, --nologger, --nologfile]
wrapper: xvfb-run -a

0 comments on commit 3615866

Please sign in to comment.