Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -728,9 +728,7 @@ in the Migration dashboard.

## Jobs Static Code Analysis Workflow

> Please note that this is an experimental workflow.

The `experimental-workflow-linter` workflow lints accessible code from 2 sources:
The `workflow-linter` workflow lints accessible code from 2 sources:
- all workflows/jobs present in the workspace
- all dashboards/queries present in the workspace
The linting emits problems indicating what to resolve for making the code Unity Catalog compatible.
Expand Down
18 changes: 11 additions & 7 deletions src/databricks/labs/ucx/assessment/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,21 @@ def crawl_groups(self, ctx: RuntimeContext):
"""Scans all groups for the local group migration scope"""
ctx.group_manager.snapshot()

@job_task
def assess_workflows(self, ctx: RuntimeContext):
"""Scans all jobs for migration issues in notebooks jobs.

Also, stores direct filesystem accesses for display in the migration dashboard.
"""
ctx.workflow_linter.refresh_report(ctx.sql_backend, ctx.inventory_database)

@job_task
def assess_dashboards(self, ctx: RuntimeContext):
"""Scans all dashboards for migration issues in SQL code of embedded widgets.
Also stores direct filesystem accesses for display in the migration dashboard."""
ctx.query_linter.refresh_report(ctx.sql_backend, ctx.inventory_database)

@job_task
def assess_workflows(self, ctx: RuntimeContext):
"""Scans all jobs for migration issues in notebooks.
Also stores direct filesystem accesses for display in the migration dashboard."""
ctx.workflow_linter.refresh_report(ctx.sql_backend, ctx.inventory_database)
Also, stores direct filesystem accesses for display in the migration dashboard.
"""
ctx.query_linter.refresh_report(ctx.sql_backend, ctx.inventory_database)


class Failing(Workflow):
Expand Down
4 changes: 2 additions & 2 deletions src/databricks/labs/ucx/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)
from databricks.labs.ucx.progress.workflows import MigrationProgress
from databricks.labs.ucx.recon.workflows import MigrationRecon
from databricks.labs.ucx.source_code.workflows import ExperimentalWorkflowLinter
from databricks.labs.ucx.source_code.workflows import WorkflowLinter
from databricks.labs.ucx.workspace_access.workflows import (
GroupMigration,
PermissionsMigrationAPI,
Expand Down Expand Up @@ -58,7 +58,7 @@ def all(cls):
ScanTablesInMounts(),
MigrateTablesInMounts(),
PermissionsMigrationAPI(),
ExperimentalWorkflowLinter(),
WorkflowLinter(),
MigrationRecon(),
Failing(),
]
Expand Down
24 changes: 14 additions & 10 deletions src/databricks/labs/ucx/source_code/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@
from databricks.labs.ucx.framework.tasks import Workflow, job_task


class ExperimentalWorkflowLinter(Workflow):
class WorkflowLinter(Workflow):
def __init__(self):
super().__init__('experimental-workflow-linter')
super().__init__('workflow-linter')

@job_task(job_cluster="table_migration")
def lint_all_workflows(self, ctx: RuntimeContext):
"""[EXPERIMENTAL] Analyses all jobs for source code compatibility problems. This is an experimental feature,
that is not yet fully supported."""
@job_task
def assess_workflows(self, ctx: RuntimeContext):
"""Scans all jobs for migration issues in notebooks jobs.

Also, stores direct filesystem accesses for display in the migration dashboard.
"""
ctx.workflow_linter.refresh_report(ctx.sql_backend, ctx.inventory_database)

@job_task(job_cluster="table_migration")
def lint_all_queries(self, ctx: RuntimeContext):
"""[EXPERIMENTAL] Analyses all jobs for source code compatibility problems. This is an experimental feature,
that is not yet fully supported."""
@job_task
def assess_dashboards(self, ctx: RuntimeContext):
"""Scans all dashboards for migration issues in SQL code of embedded widgets.

Also, stores direct filesystem accesses for display in the migration dashboard.
"""
ctx.query_linter.refresh_report(ctx.sql_backend, ctx.inventory_database)
6 changes: 3 additions & 3 deletions tests/integration/source_code/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ def test_running_real_workflow_linter_job(installation_ctx, make_job) -> None:
job = make_job(content="spark.read.table('a_table').write.csv('/mnt/things/e/f/g')\n")
ctx = installation_ctx.replace(config_transform=lambda wc: replace(wc, include_job_ids=[job.job_id]))
ctx.workspace_installation.run()
ctx.deployed_workflows.run_workflow("experimental-workflow-linter")
ctx.deployed_workflows.validate_step("experimental-workflow-linter")
ctx.deployed_workflows.run_workflow("workflow-linter")
ctx.deployed_workflows.validate_step("workflow-linter")

# This test merely tests that the workflows produces records of the expected types; record content is not checked.
cursor = ctx.sql_backend.fetch(f"SELECT COUNT(*) AS count FROM {ctx.inventory_database}.workflow_problems")
result = next(cursor)
if result['count'] == 0:
installation_ctx.deployed_workflows.relay_logs("experimental-workflow-linter")
installation_ctx.deployed_workflows.relay_logs("workflow-linter")
assert False, "No workflow problems found"
dfsa_records = installation_ctx.directfs_access_crawler_for_paths.snapshot()
used_table_records = installation_ctx.used_tables_crawler_for_paths.snapshot()
Expand Down
Loading