Skip to content
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

Raise lint errors after persisting workflow problems in the inventory database #1956

Merged
merged 2 commits into from
Jul 2, 2024
Merged
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
19 changes: 13 additions & 6 deletions src/databricks/labs/ucx/source_code/jobs.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import functools
import itertools
import logging
import tempfile
from collections.abc import Iterable
from dataclasses import dataclass
from importlib import metadata
from pathlib import Path

from databricks.labs.blueprint.parallel import Threads
from databricks.labs.blueprint.parallel import ManyError, Threads
from databricks.labs.lsql.backends import SqlBackend
from databricks.sdk import WorkspaceClient
from databricks.sdk.errors import NotFound
Expand Down Expand Up @@ -295,12 +296,18 @@ def refresh_report(self, sql_backend: SqlBackend, inventory_database: str):
logger.info(f"Preparing {len(all_jobs)} linting jobs...")
for job in all_jobs:
tasks.append(functools.partial(self.lint_job, job.job_id))
problems: list[JobProblem] = []
logger.info(f"Running {tasks} linting tasks in parallel...")
for batch in Threads.strict('linting workflows', tasks):
problems.extend(batch)
logger.info(f"Saving {len(problems)} linting problems...")
sql_backend.save_table(f'{inventory_database}.workflow_problems', problems, JobProblem, mode='overwrite')
job_problems, errors = Threads.gather('linting workflows', tasks)
logger.info(f"Saving {len(job_problems)} linting problems...")
job_problems_flattened = list(itertools.chain(*job_problems))
sql_backend.save_table(
f'{inventory_database}.workflow_problems',
job_problems_flattened,
JobProblem,
mode='overwrite',
)
if len(errors) > 0:
raise ManyError(errors)

def lint_job(self, job_id: int) -> list[JobProblem]:
try:
Expand Down
Loading