Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions labs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ commands:
description: (Optional) Name of report file to write
- name: source-tech
description: (Optional) Name of the Source System Technology you want to analyze
- name: generate-json
description: (Optional) Flag to indicate if a json file should be produced alongside the Excel file
- name: transpile
description: Transpile SQL script to Databricks SQL
flags:
Expand Down
14 changes: 10 additions & 4 deletions src/databricks/labs/lakebridge/analyzer/lakebridge_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ def _run_prompt_analyzer(self):

logger.info(f"Successfully Analyzed files in ${source_dir} for ${technology} and saved report to {results_dir}")

def _run_arg_analyzer(self, source_dir: str | None, results_dir: str | None, technology: str | None):
def _run_arg_analyzer(
self, source_dir: str | None, results_dir: str | None, technology: str | None, generate_json: bool = False
):
"""Run the analyzer: arg guided"""
if source_dir is None or results_dir is None or technology is None:
logger.error("All arguments (--source-directory, --report-file, --source-tech) must be provided")
Expand All @@ -76,7 +78,7 @@ def _run_arg_analyzer(self, source_dir: str | None, results_dir: str | None, tec
if check_path(source_dir) and check_path(results_dir):
tmp_dir = self._temp_xlsx_path(results_dir)
technology = self._get_source_tech(technology)
self._run_binary(Path(source_dir), tmp_dir, technology, self._is_debug)
self._run_binary(Path(source_dir), tmp_dir, technology, self._is_debug, generate_json)

move_tmp_file(tmp_dir, Path(results_dir))

Expand All @@ -85,11 +87,15 @@ def _run_arg_analyzer(self, source_dir: str | None, results_dir: str | None, tec
)

def run_analyzer(
self, source_dir: str | None = None, results_dir: str | None = None, technology: str | None = None
self,
source_dir: str | None = None,
results_dir: str | None = None,
technology: str | None = None,
generate_json: bool = False,
):
"""Run the analyzer."""
if not any([source_dir, results_dir, technology]):
self._run_prompt_analyzer()
return

self._run_arg_analyzer(source_dir, results_dir, technology)
self._run_arg_analyzer(source_dir, results_dir, technology, generate_json)
3 changes: 2 additions & 1 deletion src/databricks/labs/lakebridge/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,13 +651,14 @@ def analyze(
source_directory: str | None = None,
report_file: str | None = None,
source_tech: str | None = None,
generate_json: bool = False,
):
"""Run the Analyzer"""
ctx = ApplicationContext(w)
ctx.add_user_agent_extra("cmd", "analyze")

logger.debug(f"User: {ctx.current_user}")
ctx.analyzer.run_analyzer(source_directory, report_file, source_tech)
ctx.analyzer.run_analyzer(source_directory, report_file, source_tech, generate_json)


if __name__ == "__main__":
Expand Down
Loading