-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Changes Track `DirectFsAccess` on `JobsProgressEncoder` ### Linked issues Resolves #3059 ### Functionality - [x] modified existing workflow: `migration-progress-experimental` ### Tests - [x] added unit tests - [x] added integration tests
- Loading branch information
1 parent
bccc103
commit 438ffc8
Showing
6 changed files
with
172 additions
and
17 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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,86 @@ | ||
from databricks.labs.ucx.assessment.jobs import JobInfo | ||
from databricks.labs.ucx.framework.utils import escape_sql_identifier | ||
from databricks.labs.ucx.source_code.base import DirectFsAccess, LineageAtom | ||
from databricks.labs.ucx.source_code.jobs import JobProblem | ||
|
||
|
||
def test_job_progress_encoder_failures(runtime_ctx, az_cli_ctx) -> None: | ||
az_cli_ctx.progress_tracking_installation.run() | ||
runtime_ctx = runtime_ctx.replace( | ||
parent_run_id=1, | ||
sql_backend=az_cli_ctx.sql_backend, | ||
ucx_catalog=az_cli_ctx.ucx_catalog, | ||
) | ||
|
||
job = runtime_ctx.make_job() | ||
assert job.job_id, "Expected job with id" | ||
assert job.settings and job.settings.tasks, "Expected job with tasks" | ||
|
||
job_problems = [ | ||
JobProblem( | ||
job_id=job.job_id, | ||
job_name=job.settings.name, | ||
task_key=job.settings.tasks[0].task_key, | ||
path="parent/child.py", | ||
code="sql-parse-error", | ||
message="Could not parse SQL", | ||
start_line=12, | ||
start_col=0, | ||
end_line=12, | ||
end_col=20, | ||
) | ||
] | ||
runtime_ctx.sql_backend.save_table( | ||
f'{runtime_ctx.inventory_database}.workflow_problems', | ||
job_problems, | ||
JobProblem, | ||
mode='overwrite', | ||
) | ||
|
||
dashboard = runtime_ctx.make_dashboard() | ||
|
||
direct_fs_access_for_path = DirectFsAccess( | ||
source_id="/path/to/write_dfsa.py", | ||
source_lineage=[ | ||
LineageAtom(object_type="WORKFLOW", object_id=str(job.job_id), other={"name": job.settings.name}), | ||
LineageAtom(object_type="TASK", object_id=job.settings.tasks[0].task_key), | ||
], | ||
path="dfsa:/path/to/data/", | ||
is_read=False, | ||
is_write=True, | ||
) | ||
runtime_ctx.directfs_access_crawler_for_paths.dump_all([direct_fs_access_for_path]) | ||
|
||
direct_fs_access_for_query = DirectFsAccess( | ||
source_id="/path/to/write_dfsa.py", | ||
source_lineage=[ | ||
LineageAtom( | ||
object_type="DASHBOARD", | ||
object_id=dashboard.id, | ||
other={"parent": dashboard.parent, "name": dashboard.name}, | ||
), | ||
LineageAtom(object_type="QUERY", object_id=f"{dashboard.id}/query", other={"name": "test"}), | ||
], | ||
path="dfsa:/path/to/data/", | ||
is_read=False, | ||
is_write=True, | ||
) | ||
runtime_ctx.directfs_access_crawler_for_queries.dump_all([direct_fs_access_for_query]) | ||
|
||
job_info = JobInfo( | ||
str(job.job_id), | ||
success=1, | ||
failures="[]", | ||
job_name=job.settings.name, | ||
creator=job.creator_user_name, | ||
) | ||
runtime_ctx.jobs_progress.append_inventory_snapshot([job_info]) | ||
|
||
history_table_name = escape_sql_identifier(runtime_ctx.tables_progress.full_name) | ||
records = list(runtime_ctx.sql_backend.fetch(f"SELECT * FROM {history_table_name}")) | ||
|
||
assert len(records) == 1, "Expected one historical entry" | ||
assert records[0].failures == [ | ||
f"sql-parse-error: {job.settings.tasks[0].task_key} task: parent/child.py: Could not parse SQL", | ||
f"direct-filesystem-access: {job.settings.tasks[0].task_key} task: /path/to/write_dfsa.py: The use of direct filesystem references is deprecated: dfsa:/path/to/data/", | ||
] |
This file contains 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