Skip to content

Commit 8c509a5

Browse files
authored
Merge pull request #29 from thisisqubika/DC-353-fix
fix on output folder logic to include eval results
2 parents 21fac39 + 8c8f3fa commit 8c509a5

8 files changed

Lines changed: 242 additions & 86 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,27 @@ Notes:
138138
- `make translate` invokes the script at `scripts/run_translation.sh` and is the cleanest option.
139139
- The script exports `PYTHONPATH=src` so you can run it from the repository root.
140140
- Output is written to `src/artifact_translation_package/out_sql_examples_<timestamp>`.
141+
142+
Local vs Databricks output paths
143+
--------------------------------
144+
145+
This project uses Databricks-style paths (for example `dbfs:/...`) as the canonical configuration. To make the same code run locally without changing the canonical config, the runner maps Databricks paths to a local directory when it detects a non-Databricks runtime.
146+
147+
- **Local mapping environment variable**: set `LOCAL_DBFS_MOUNT` to the local directory that should act as the root for `dbfs:/` paths. Default: `./ddl_output`.
148+
- **Per-run `results_dir`**: when running the translation job locally (for example via `make translate`), the job pre-creates a timestamped `results_dir` and propagates it to the translation context. Evaluation results are written under `<results_dir>/evaluation_results/`. Translation outputs such as `translation_results.json` and `results_summary.json` are written into the same `results_dir`.
149+
- **Fallback behavior**: the runner also exports `DDL_OUTPUT_DIR=<results_dir>` so code paths that read the `DDL_OUTPUT_DIR` environment variable will also target the per-run folder.
150+
151+
Examples
152+
153+
```bash
154+
# run with default local mapping (output under ./ddl_output by default)
155+
make translate
156+
157+
# override where dbfs:/ maps to locally
158+
export LOCAL_DBFS_MOUNT=/tmp/my_local_dbfs
159+
make translate
160+
161+
# inspect latest run outputs
162+
ls -la src/artifact_translation_package/out_sql_examples_*/
163+
ls -la <that-run-folder>/evaluation_results/
164+
```

scripts/run_translation.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ BATCH_SIZE=${2:-2}
99
FORMAT=${3:-sql}
1010

1111
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
12-
OUT_DIR="src/artifact_translation_package/out_sql_examples_${TIMESTAMP}"
12+
# Prefer an explicit DDL_OUTPUT_DIR if provided (e.g. from .env). Otherwise
13+
# fall back to creating a timestamped out_sql_examples_<timestamp> folder.
14+
OUT_DIR="${DDL_OUTPUT_DIR:-src/artifact_translation_package/out_sql_examples_${TIMESTAMP}}"
1315

1416
echo "-> Running translation job"
1517
echo " examples: ${EXAMPLES_GLOB}"
1618
echo " batch size: ${BATCH_SIZE}"
1719
echo " output format: ${FORMAT}"
18-
echo " output dir: ${OUT_DIR}"
20+
echo " output dir: ${OUT_DIR} (DDL_OUTPUT_DIR=${DDL_OUTPUT_DIR:-unset})"
1921

2022
mkdir -p "$OUT_DIR"
2123

src/artifact_translation_package/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,28 @@ DATABRICKS_TOKEN=your-databricks-token
164164
DDL_OUTPUT_DIR=./output
165165
```
166166

167+
### Local vs Databricks output paths
168+
169+
- Databricks is the canonical runtime and configuration may reference DBFS paths like `dbfs:/some/base`.
170+
- When running locally (for example via `make translate` or the provided run scripts), the code will automatically map `dbfs:/...` paths to a local directory so outputs are written to your machine.
171+
- Control the local mapping with the `LOCAL_DBFS_MOUNT` environment variable (default: `./ddl_output`). Example:
172+
173+
```bash
174+
# use default local mapping
175+
make translate
176+
177+
# override local mapping directory
178+
export LOCAL_DBFS_MOUNT=./my_local_dbfs_mount
179+
make translate
180+
```
181+
182+
- Evaluation/validation JSON files are written into the per-run timestamped results folder under an `evaluation_results/` subdirectory (not into a global `ddl_output/evaluation_results` folder) when an output path is used. This keeps SQL, JSON, and evaluation artifacts grouped by run for easier inspection.
183+
184+
Note: the included `scripts/run_translation.sh` helper prefers the `DDL_OUTPUT_DIR` environment
185+
variable when present (for example from your `.env` file). If `DDL_OUTPUT_DIR` is unset the helper
186+
falls back to creating `src/artifact_translation_package/out_sql_examples_<timestamp>` as before.
187+
188+
167189
## Architecture
168190

169191
### Translation Graph

src/artifact_translation_package/config/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class LangGraphConfig(Enum):
1414
#DDL Settings
1515
DDL_BATCH_SIZE = 8
1616
# Default outputs for Databricks should go to a Volume mounted path
17-
DDL_OUTPUT_DIR = "/Volumes/qubika_partner_solutions.migration_accelerator.outputs"
17+
# Use segmented path segments: /Volumes/<catalog>/<schema>/<volume_name>/
18+
DDL_OUTPUT_DIR = "/Volumes/qubika_partner_solutions/migration_accelerator/outputs"
1819

1920
# Optional: DDL Generation Settings
2021
#DDL_CATALOG_NAME= "demo_catalog"

0 commit comments

Comments
 (0)