Skip to content

Commit

Permalink
move results to another directory, create missing result directories (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
reschandreas authored Dec 18, 2023
1 parent cdff5d9 commit 5e8b1bb
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cli/generators/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class CliGenerator(BaseGenerator):
functions: List[str] = []

initial_directory_variable: str = "AEOLUS_INITIAL_DIRECTORY"
results_directory_variable: str = "/var/tmp/aeolus-results"

def __init__(
self, windfile: WindFile, input_settings: InputSettings, output_settings: OutputSettings, metadata: PassMetadata
Expand Down Expand Up @@ -74,7 +75,7 @@ def add_postfix(self) -> None:
self.add_line(indentation=2, line="trap final_aeolus_post_action EXIT")
for function in self.functions:
self.add_line(
indentation=2, line=f'sh -c "source ${{_scriptname}} aeolus_sourcing;{function} $_current_lifecycle"'
indentation=2, line=f'bash -c "source ${{_scriptname}} aeolus_sourcing;{function} $_current_lifecycle"'
)
self.add_line(indentation=2, line=f"cd ${self.initial_directory_variable}")
self.result.append("}\n")
Expand Down Expand Up @@ -128,15 +129,17 @@ def handle_results(self) -> None:
self.result.append("\n# move results")
self.result.append("aeolus_move_results () " + "{")
self.add_line(indentation=2, line="echo '⚙️ moving results'")
self.add_line(indentation=2, line="mkdir -p /aeolus-results")
self.add_line(indentation=2, line=f"mkdir -p {self.results_directory_variable}")
self.add_line(indentation=2, line="shopt -s extglob")
for workdir, entries in self.results.items():
self.add_line(indentation=2, line=f"cd {workdir}")
for result in entries:
self.add_line(indentation=2, line=f'local _sources="{result.path}"')
self.add_line(indentation=2, line="local _directory=$(dirname $_sources)")
if result.ignore:
self.add_line(indentation=2, line=f"_sources=$(echo $_sources/!({result.ignore}))")
self.add_line(indentation=2, line=f"mv $_sources /aeolus-results/{result.path}")
self.add_line(indentation=2, line=f"mkdir -p {self.results_directory_variable}/$_directory")
self.add_line(indentation=2, line=f"mv $_sources {self.results_directory_variable}/{result.path}")
self.result.append("}")

def handle_step_results(self, workdir: Optional[str], step: ScriptAction) -> None:
Expand Down

0 comments on commit 5e8b1bb

Please sign in to comment.