Skip to content

Commit c832375

Browse files
authored
Organise modules by domain (#197)
This simplifies code and moves modules and classes by their respective domains/components, roughly mapped on folders. This is a change from the previous diamond-shaped cross-module dependency layout, which is harder to evolve. Main tenets be: - any component can depend on `mixins` (staging are for SDK) and `framework` (common modules). - tight coupling is allowed within a single component. An example is local group migration, which exposes a single high-level migration toolkit (`from databricks.labs.ucx.workspace_access import GroupMigrationToolkit`) and leaves implementation details private. Another example is a toolkit to migrate from HMS to UC DDL. - all execution is either triggered from `install` (which also handles update) or `runtime` (as the entrypoint for jobs). Multiple toolkits may be combined into a single Databricks Workflows (aka Jobs) - e.g. pulling permissions and tables inventory is necessary for the assessment step, but later the Workflows may branch out. - if two classes are used together in 90% of cases, they have to be defined in the single file (aka Python Module). We don't define `types` and `managers` modules/packages, as this is an example of a diamond-shaped dependencies, which are more difficult to evolve over time. - methods and fields have to be private by default. make them public only by necessity. - classes must have the following order - __init__, overridden methods, public methods, other methods. the most important logic has to be first.
1 parent 9b362c4 commit c832375

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+1114
-1298
lines changed

notebooks/toolkit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
MigrationConfig,
1818
TaclConfig,
1919
)
20-
from databricks.labs.ucx.toolkits.group_migration import GroupMigrationToolkit
21-
from databricks.labs.ucx.toolkits.table_acls import TaclToolkit
20+
from databricks.labs.ucx.workspace_access import GroupMigrationToolkit
21+
from databricks.labs.ucx.hive_metastore import TaclToolkit
2222

2323
# COMMAND ----------
2424

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,14 @@ ban-relative-imports = "all"
163163
"ARG001" # tests may not use the provided fixtures
164164
]
165165

166-
"src/databricks/labs/ucx/providers/mixins/redash.py" = ["A002", "A003", "N815"]
166+
"src/databricks/labs/ucx/mixins/redash.py" = ["A002", "A003", "N815"]
167167

168168
[tool.coverage.run]
169169
branch = true
170170
parallel = true
171171

172172
[tool.coverage.report]
173-
omit = ["src/databricks/labs/ucx/providers/mixins/*"]
173+
omit = ["src/databricks/labs/ucx/mixins/*"]
174174
exclude_lines = [
175175
"no cov",
176176
"if __name__ == .__main__.:",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from databricks.labs.ucx.logger import _install
1+
from databricks.labs.ucx.framework.logger import _install
22

33
_install()

src/databricks/labs/ucx/toolkits/assessment.py renamed to src/databricks/labs/ucx/assessment/assessment.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from databricks.sdk.service.compute import Language
77

88
from databricks.labs.ucx.assessment import commands
9-
from databricks.labs.ucx.providers.mixins.compute import CommandExecutor
9+
from databricks.labs.ucx.mixins.compute import CommandExecutor
1010

1111
logger = logging.getLogger(__name__)
1212

src/databricks/labs/ucx/tacl/_internal.py renamed to src/databricks/labs/ucx/framework/crawlers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from databricks.sdk import WorkspaceClient
88

9-
from databricks.labs.ucx.providers.mixins.sql import StatementExecutionExt
9+
from databricks.labs.ucx.mixins.sql import StatementExecutionExt
1010

1111
logger = logging.getLogger(__name__)
1212

File renamed without changes.

src/databricks/labs/ucx/utils.py renamed to src/databricks/labs/ucx/framework/parallel.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
from concurrent.futures import ALL_COMPLETED, ThreadPoolExecutor
66
from typing import Generic, TypeVar
77

8-
from databricks.labs.ucx.generic import StrEnum
9-
108
ExecutableResult = TypeVar("ExecutableResult")
119
ExecutableFunction = Callable[..., ExecutableResult]
1210
logger = logging.getLogger(__name__)
@@ -66,20 +64,5 @@ def run(self) -> list[ExecutableResult]:
6664
return collected
6765

6866

69-
class Request:
70-
def __init__(self, req: dict):
71-
self.request = req
72-
73-
def as_dict(self) -> dict:
74-
return self.request
75-
76-
77-
class WorkspaceLevelEntitlement(StrEnum):
78-
WORKSPACE_ACCESS = "workspace-access"
79-
DATABRICKS_SQL_ACCESS = "databricks-sql-access"
80-
ALLOW_CLUSTER_CREATE = "allow-cluster-create"
81-
ALLOW_INSTANCE_POOL_CREATE = "allow-instance-pool-create"
82-
83-
8467
def noop():
8568
pass

src/databricks/labs/ucx/tasks.py renamed to src/databricks/labs/ucx/framework/tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from pathlib import Path
66

77
from databricks.labs.ucx.config import MigrationConfig
8-
from databricks.labs.ucx.logger import _install
8+
from databricks.labs.ucx.framework.logger import _install
99

1010
_TASKS: dict[str, "Task"] = {}
1111

src/databricks/labs/ucx/generic.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)