-
Notifications
You must be signed in to change notification settings - Fork 96
Added export CLI functionality for assessment results #2553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
93 commits
Select commit
Hold shift + click to select a range
4f0c6dc
initial draft of remote dashboads widgets collection
rportilla-databricks d288e0a
Creating new branch without committing any files
rportilla-databricks 5aee6b6
Cherry-pick commit 60f957e
rportilla-databricks afc714c
test
lmallepaddi ad01abb
test commit
lmallepaddi f26c522
Added UCX Export Result notebook as Utility Hack
jgarciaf106 522d43e
add test files
rportilla-databricks 0c7083d
updated unit tests
rportilla-databricks 66dbab1
Merge pull request #1 from rportilla-databricks/feat/ucx-export-notebook
rportilla-databricks 32adee0
Update workflows.py
jgarciaf106 77a88cd
Merge pull request #3 from rportilla-databricks/feat/add_exporter
rportilla-databricks 9db2d70
Merge pull request #2 from rportilla-databricks/export-notebook-patch-1
rportilla-databricks 33f1f11
Adding unit tests coverage
lmallepaddi 898eeef
fullset unit test cases and slight changes to export.py file
lmallepaddi 2c8e92b
Removed unnecessary imports
lmallepaddi d6243ad
Merge pull request #4 from rportilla-databricks/feat/add_exporter
rportilla-databricks 99bf9a1
updated tests
rportilla-databricks ee446f1
update cli for export
rportilla-databricks e57cbfe
update test format
rportilla-databricks 1240c63
Merge branch 'main' into main
rportilla-databricks 5cdeb3c
Update src/databricks/labs/ucx/assessment/export.py
rportilla-databricks c63904e
add structural changes
rportilla-databricks 8b71454
Integrated lsql functionality to export the Assessment Results
jgarciaf106 a8a325e
Minor Changes
jgarciaf106 6ebc90c
Merge branch 'main' into feat/cli-assessment-export
rportilla-databricks f47f125
Merge pull request #7 from jgarciaf106/feat/cli-assessment-export
rportilla-databricks cd67ee4
naming change missed in cli.py
rportilla-databricks 3e8d342
correcting use of the cached property
rportilla-databricks 92fd1c0
fix cached property
rportilla-databricks e5e2e10
fix cli
rportilla-databricks a71b086
Removed flags as there are code provides prompts
lmallepaddi 21785e4
added command line usage in readme file
lmallepaddi 077a03f
Merge pull request #8 from rportilla-databricks/feat/add_exporter
rportilla-databricks 14fa408
minor change to export.py to resolve unit test case issue
lmallepaddi 8d607c8
fix errors and address feedback
rportilla-databricks 20c19f2
updated syntax for export
rportilla-databricks cf6fa3c
Merge branch 'main' into feat/add_exporter
lmallepaddi 6a33aca
Update src/databricks/labs/ucx/cli.py
rportilla-databricks 7b798aa
Update src/databricks/labs/ucx/installer/workflows.py
rportilla-databricks 66c281f
Update workflows.py
jgarciaf106 a00ecf8
Merge pull request #10 from rportilla-databricks/Workflows-patch-3
rportilla-databricks 92937ce
revert tmp path
rportilla-databricks b4d58d5
changes to README.md and test_export.py
lmallepaddi 4599dfa
Merge pull request #9 from rportilla-databricks/feat/add_exporter
rportilla-databricks dce6f86
Merge branch 'databrickslabs:main' into feat/add_exporter
rportilla-databricks d61a5ce
Merge branch 'databrickslabs:main' into main
rportilla-databricks 8c7dd67
Merge pull request #11 from rportilla-databricks/feat/add_exporter
rportilla-databricks d94d581
update the logical name of the collection of queries
rportilla-databricks 007891d
update reference
rportilla-databricks 598c596
Updated notebook content to Use triple quotes
jgarciaf106 82146db
Merge pull request #12 from rportilla-databricks/export_notebook/patch
rportilla-databricks f4b7170
zip file rename functionality
lmallepaddi 90a8189
changed readme file to reflect changes to zipfilename
lmallepaddi 5eb417c
Changes to export.py using lsql version 0.11
lmallepaddi 9069f3d
updated the test_cli.py for filename change
lmallepaddi 44b4ac4
remove print statement
rportilla-databricks bcfd6e1
Merge pull request #13 from rportilla-databricks/feat/add_exporter
rportilla-databricks f90d2c1
Merge branch 'main' into main
nfx 6e3ddf9
Export Results simplification
jgarciaf106 26799fc
Merge pull request #14 from rportilla-databricks/patch-export
rportilla-databricks b2e3c85
Fixed Unit Tests for Export Assessment
jgarciaf106 9fb3f49
Merge pull request #15 from rportilla-databricks/patch-export
rportilla-databricks 3d567b4
Merge branch 'databrickslabs:main' into main
rportilla-databricks ae5832d
make fmt run
rportilla-databricks 204ab4a
Minor contributor documentation changes (#2729)
asnare 0a6e72f
Handle `PermissionDenied` when listing accessible workspaces (#2733)
JCZuurmond 93d496e
Adding unskip CLI command to undo a skip on schema or a table (#2727)
aminmovahed-db ee20112
Fix failing integration tests that perform a real assessment (#2736)
ericvergnaud 2f62a0f
Update documentation to explain the usage of collections and eligible…
HariGS-DB 8fee9d8
Enables cli cmd `databricks labs ucx create-catalog-schemas` to apply…
HariGS-DB 21da7cc
Add `create-ucx-catalog` cli command (#2694)
JCZuurmond 2a09a8f
Fixes issue of circular dependency of migrate-location ACL (#2741)
HariGS-DB d1dd0c5
Added static code analysis results to assessment dashboard (#2696)
ericvergnaud 7cba9b0
Increases test coverage (#2739)
pritishpai 04a4956
Fixes source table alias dissapearance during migrate_views (#2726)
pritishpai 15c5536
Bump astroid version, pylint version and drop our f-string workaround…
ericvergnaud 2611b11
Update databricks-labs-blueprint requirement from <0.9,>=0.8 to >=0.8…
dependabot[bot] 555e83a
Delete temporary files when running solacc (#2750)
ericvergnaud d744465
Code format: `make fmt` (#2749)
asnare 04918be
Speedup assessment workflow by making DBFS root table size calculatio…
nfx 0a03def
Harden configuration reading (#2701)
JCZuurmond be955ea
Add unskip CLI command to undo a skip on schema or a table (#2734)
aminmovahed-db 788c273
Improve solacc linting (#2752)
ericvergnaud 1d12391
Sync Fork, make fmt test
jgarciaf106 d3a0e39
Merge pull request #16 from rportilla-databricks/patch-export-v2
rportilla-databricks 4d2e9a6
Merge branch 'databrickslabs:main' into main
rportilla-databricks b163801
Added CLI Functionality to export UCX Assessment
jgarciaf106 188bc24
Added CLI Functionality to export UCX Assessment
jgarciaf106 cb89541
Added CLI Functionality to export UCX Assessment
jgarciaf106 571fc8b
Added CLI Functionality to export UCX Assessment
jgarciaf106 77786a2
Merge branch 'main' into feat/add-cli-export-assessment-reviewed
rportilla-databricks 84830fd
Merge pull request #21 from jgarciaf106/feat/add-cli-export-assessmen…
rportilla-databricks 2975950
Merge branch 'main' into main
jgarciaf106 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import logging | ||
from pathlib import Path | ||
|
||
from databricks.labs.blueprint.tui import Prompts | ||
|
||
from databricks.labs.ucx.config import WorkspaceConfig | ||
from databricks.labs.lsql.backends import SqlBackend | ||
from databricks.labs.lsql.dashboards import DashboardMetadata | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class AssessmentExporter: | ||
|
||
def __init__(self, sql_backend: SqlBackend, config: WorkspaceConfig): | ||
self._sql_backend = sql_backend | ||
self._config = config | ||
|
||
def export_results(self, prompts: Prompts): | ||
"""Main method to export results to CSV files inside a ZIP archive.""" | ||
project_root = Path(__file__).resolve().parents[3] | ||
queries_path_root = project_root / "labs/ucx/queries/assessment" | ||
|
||
results_directory = Path( | ||
prompts.question( | ||
"Choose a path to save the UCX Assessment results", | ||
default=Path.cwd().as_posix(), | ||
validate=lambda p_: Path(p_).exists(), | ||
) | ||
) | ||
|
||
query_choice = prompts.choice( | ||
"Choose which assessment results to export", | ||
[subdir.name for subdir in queries_path_root.iterdir() if subdir.is_dir()], | ||
) | ||
|
||
export_path = results_directory / f"export_{query_choice}_results.zip" | ||
queries_path = queries_path_root / query_choice | ||
|
||
assessment_results = DashboardMetadata.from_path(queries_path).replace_database( | ||
database=self._config.inventory_database, database_to_replace="inventory" | ||
) | ||
|
||
logger.info("Exporting assessment results....") | ||
results_path = assessment_results.export_to_zipped_csv(self._sql_backend, export_path) | ||
logger.info(f"Results exported to {results_path}") | ||
|
||
return results_path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ | |
from databricks.labs.ucx.install import AccountInstaller | ||
from databricks.labs.ucx.source_code.linters.files import LocalCodeLinter | ||
|
||
|
||
ucx = App(__file__) | ||
logger = get_logger(__file__) | ||
|
||
|
@@ -791,5 +792,13 @@ def lint_local_code( | |
linter.lint(prompts, None if path is None else Path(path)) | ||
|
||
|
||
@ucx.command | ||
def export_assessment(w: WorkspaceClient, prompts: Prompts): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like a duplicate of the above command? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed now. |
||
"""Export the UCX assessment queries to a zip file.""" | ||
ctx = WorkspaceContext(w) | ||
exporter = ctx.assessment_exporter | ||
exporter.export_results(prompts) | ||
|
||
|
||
if __name__ == "__main__": | ||
ucx() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from databricks.labs.ucx.config import WorkspaceConfig | ||
from databricks.labs.ucx.assessment.export import AssessmentExporter | ||
from databricks.labs.lsql.backends import MockBackend | ||
from databricks.labs.blueprint.tui import MockPrompts | ||
from databricks.labs.lsql.core import Row | ||
|
||
|
||
def test_export(tmp_path): | ||
"""Test the export_results method of the AssessmentExporter class.""" | ||
query = { | ||
"SELECT\n one\nFROM ucx.external_locations": [ | ||
Row(location="s3://bucket1/folder1", table_count=1), | ||
Row(location="abfss://container1@storage1.dfs.core.windows.net/folder1", table_count=1), | ||
Row(location="gcp://folder1", table_count=2), | ||
] | ||
} | ||
|
||
# Setup workspace configuration | ||
config = WorkspaceConfig(inventory_database="ucx") | ||
|
||
# Prepare temporary paths and files | ||
export_path = tmp_path / "export" | ||
export_path.mkdir(parents=True, exist_ok=True) | ||
|
||
# Mock backend and prompts | ||
mock_backend = MockBackend(rows=query) | ||
query_choice = {"assessment_name": "main", "option": 3} | ||
mock_prompts = MockPrompts( | ||
{ | ||
"Choose a path to save the UCX Assessment results": export_path.as_posix(), | ||
"Choose which assessment results to export": query_choice["option"], | ||
} | ||
) | ||
|
||
# Execute export process | ||
export = AssessmentExporter(mock_backend, config) | ||
exported = export.export_results(mock_prompts) | ||
|
||
# Assertion based on the query_choice | ||
expected_file_name = f"export_{query_choice['assessment_name']}_results.zip" # Adjusted filename | ||
assert exported == export_path / expected_file_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant newlines