Skip to content

Commit f1211e5

Browse files
committed
saving report to timestamped folder instead of outputs
1 parent 3a530b8 commit f1211e5

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/migration_report_package/graph_builder.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
class MigrationState(TypedDict):
1313
"""State for the migration graph execution."""
1414
input_dir: str
15+
latest_dir: str
1516
raw: Dict[str, Any]
1617
cleaned_raw: Dict[str, Any]
1718
count: Dict[str, Any]
@@ -33,6 +34,7 @@ def input_node(state: MigrationState) -> MigrationState:
3334
output_dirs.append((run_dt, res))
3435

3536
_ , latest = max(output_dirs, key=lambda x: x[0])
37+
state["latest_dir"] = latest
3638
## Get translation results and evaluation notes
3739
raw = {"translation_results": [], "evaluation": []}
3840
for name in os.listdir(latest):
@@ -142,6 +144,7 @@ def run(self, input_path: str) -> Dict[str, Any]:
142144
try:
143145
initial_state: MigrationState = {
144146
"input_dir": input_path,
147+
"latest_dir": None,
145148
"raw": [],
146149
"count": None,
147150
"json_report": None,
@@ -151,7 +154,8 @@ def run(self, input_path: str) -> Dict[str, Any]:
151154
final_state = self.compiled_graph.invoke(initial_state)
152155
report = final_state["md_report"] or {}
153156
json_report = final_state["json_report"] or {}
154-
return report[0], json_report
157+
latest_dir = final_state["latest_dir"] or {}
158+
return report[0], json_report, latest_dir
155159

156160
except Exception as e:
157161
raise

src/migration_report_package/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ def main():
6060
if args.output_dir:
6161
input_dir = os.path.dirname(args.output_dir)
6262

63-
md_report, json_report = graph.run(input_dir)
63+
md_report, json_report, latest_dir = graph.run(input_dir)
6464

6565
print("Report done!")
6666

6767
if args.md_output:
6868
output_dir = os.path.dirname(args.md_output)
6969

70-
save_results(output_dir,md_report)
70+
save_results(latest_dir,md_report)
7171

7272
print("JSON Report: ",json_report)
7373

0 commit comments

Comments
 (0)