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

Split DeployedWorkflows out of WorkflowsDeployment #1248

Merged
merged 1 commit into from
Apr 3, 2024
Merged
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
9 changes: 5 additions & 4 deletions src/databricks/labs/ucx/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
@ucx.command
def workflows(w: WorkspaceClient):
"""Show deployed workflows and their state"""
installation = WorkflowsDeployment.current(w)
installation = WorkflowsDeployment.for_cli(w)
logger.info("Fetching deployed jobs...")
print(json.dumps(installation.latest_job_status()))

Expand Down Expand Up @@ -161,16 +161,17 @@ def validate_external_locations(w: WorkspaceClient, prompts: Prompts):
@ucx.command
def ensure_assessment_run(w: WorkspaceClient):
"""ensure the assessment job was run on a workspace"""
installation = WorkspaceInstallation.current(w)
installation.validate_and_run("assessment")
deployed_workflows = WorkflowsDeployment.for_cli(w)
if not deployed_workflows.validate_step("assessment"):
deployed_workflows.run_workflow("assessment")


@ucx.command
def repair_run(w: WorkspaceClient, step):
"""Repair Run the Failed Job"""
if not step:
raise KeyError("You did not specify --step")
installation = WorkflowsDeployment.current(w)
installation = WorkflowsDeployment.for_cli(w)
logger.info(f"Repair Running {step} Job")
installation.repair_run(step)

Expand Down
4 changes: 0 additions & 4 deletions src/databricks/labs/ucx/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,6 @@ def _remove_warehouse(self):
except InvalidParameterValue:
logger.error("Error accessing warehouse details")

def validate_and_run(self, step: str):
if not self._workflows_installer.validate_step(step):
self._workflows_installer.run_workflow(step)

def _trigger_workflow(self, step: str):
job_id = int(self._install_state.jobs[step])
job_url = f"{self._ws.config.host}#job/{job_id}"
Expand Down
18 changes: 0 additions & 18 deletions src/databricks/labs/ucx/installer/mixins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import logging
import os
from datetime import datetime

from databricks.labs.blueprint.installation import Installation
from databricks.sdk import WorkspaceClient
Expand Down Expand Up @@ -31,23 +30,6 @@ def _my_username(self):
raise PermissionError(msg)
return self._me.user_name

@staticmethod
def _readable_timedelta(epoch):
when = datetime.utcfromtimestamp(epoch)
duration = datetime.now() - when
data = {}
data["days"], remaining = divmod(duration.total_seconds(), 86_400)
data["hours"], remaining = divmod(remaining, 3_600)
data["minutes"], data["seconds"] = divmod(remaining, 60)

time_parts = ((name, round(value)) for (name, value) in data.items())
time_parts = [f"{value} {name[:-1] if value == 1 else name}" for name, value in time_parts if value > 0]
if len(time_parts) > 0:
time_parts.append("ago")
if time_parts:
return " ".join(time_parts)
return "less than 1 second ago"

@property
def _warehouse_id(self) -> str:
if self._config.warehouse_id is not None:
Expand Down
Loading
Loading