Skip to content

Commit 1a07212

Browse files
authored
Rely on rate limiting from Databricks SDK for listing workspace (#258)
1 parent c5e20d9 commit 1a07212

File tree

7 files changed

+25
-19
lines changed

7 files changed

+25
-19
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from databricks.labs.ucx.hive_metastore.grants import GrantsCrawler
2-
from databricks.labs.ucx.hive_metastore.list_mounts import Mounts
2+
from databricks.labs.ucx.hive_metastore.mounts import Mounts
33
from databricks.labs.ucx.hive_metastore.tables import TablesCrawler
44

55
__all__ = ["TablesCrawler", "GrantsCrawler", "Mounts"]

src/databricks/labs/ucx/hive_metastore/data_objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from databricks.sdk import WorkspaceClient
66

77
from databricks.labs.ucx.framework.crawlers import CrawlerBase, SqlBackend
8-
from databricks.labs.ucx.hive_metastore.list_mounts import Mounts
8+
from databricks.labs.ucx.hive_metastore.mounts import Mounts
99
from databricks.labs.ucx.mixins.sql import Row
1010

1111

src/databricks/labs/ucx/runtime.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from databricks.labs.ucx.framework.tasks import task, trigger
1111
from databricks.labs.ucx.hive_metastore import GrantsCrawler, TablesCrawler
1212
from databricks.labs.ucx.hive_metastore.data_objects import ExternalLocationCrawler
13-
from databricks.labs.ucx.hive_metastore.list_mounts import Mounts
13+
from databricks.labs.ucx.hive_metastore.mounts import Mounts
1414
from databricks.labs.ucx.workspace_access import GroupMigrationToolkit
1515

1616
logger = logging.getLogger(__name__)
@@ -55,7 +55,7 @@ def crawl_grants(cfg: MigrationConfig):
5555

5656

5757
@task("assessment", depends_on=[setup_schema])
58-
def inventorize_mounts(cfg: MigrationConfig):
58+
def crawl_mounts(cfg: MigrationConfig):
5959
"""In this segment of the assessment, we will define the scope of the mount points intended for migration into the
6060
Unity Catalog. As these objects are not compatible with the Unity Catalog paradigm, a key component of the
6161
migration process involves transferring them to Unity Catalog External Locations.
@@ -68,8 +68,8 @@ def inventorize_mounts(cfg: MigrationConfig):
6868
mounts.inventorize_mounts()
6969

7070

71-
@task("assessment", depends_on=[inventorize_mounts, crawl_tables])
72-
def inventorize_external_locations(cfg: MigrationConfig):
71+
@task("assessment", depends_on=[crawl_mounts, crawl_tables])
72+
def guess_external_locations(cfg: MigrationConfig):
7373
"""In this section of the assessment, our objective is to determine the whereabouts of all the tables.
7474
Specifically, we will focus on identifying locations that utilize Mount Points. Our goal is to identify the
7575
External Locations necessary for a successful migration and store this information in the
@@ -86,11 +86,11 @@ def inventorize_external_locations(cfg: MigrationConfig):
8686

8787

8888
@task("assessment", depends_on=[setup_schema])
89-
def inventorize_jobs(cfg: MigrationConfig):
89+
def assess_jobs(cfg: MigrationConfig):
9090
"""This module scans through all the jobs and identifies those that are not compatible with UC.
9191
It looks for:
9292
- Clusters with DBR version earlier than 11.3
93-
- Clusters using Passthru Authentication
93+
- Clusters using Passthrough Authentication
9494
- Clusters with incompatible spark config tags
9595
- Clusters referencing DBFS locations in one or more config options
9696
Subsequently, the list of all the jobs is stored in the `$inventory.jobs` table."""
@@ -100,11 +100,11 @@ def inventorize_jobs(cfg: MigrationConfig):
100100

101101

102102
@task("assessment", depends_on=[setup_schema])
103-
def inventorize_clusters(cfg: MigrationConfig):
103+
def assess_clusters(cfg: MigrationConfig):
104104
"""This module scan through all the clusters and identifies those that are not compatible with UC.
105105
It looks for:
106106
- Clusters with DBR version earlier than 11.3
107-
- Clusters using Passthru Authentication
107+
- Clusters using Passthrough Authentication
108108
- Clusters with incompatible spark config tags
109109
- Clusters referencing DBFS locations in one or more config options
110110
Subsequently, the list of all the clusters is stored in the`$inventory.clusters` table."""
@@ -114,7 +114,7 @@ def inventorize_clusters(cfg: MigrationConfig):
114114

115115

116116
@task("assessment", depends_on=[setup_schema])
117-
def inventorize_permissions(cfg: MigrationConfig):
117+
def crawl_permissions(cfg: MigrationConfig):
118118
"""As we commence the intricate migration process from Hive Metastore to the Databricks Unity Catalog, a critical
119119
element of this transition is the thorough examination and preservation of permissions linked to a wide array of
120120
Databricks Workspace components. These components encompass a broad spectrum of resources, including clusters,
@@ -128,12 +128,15 @@ def inventorize_permissions(cfg: MigrationConfig):
128128
meticulous scan are methodically stored within the `$inventory.permissions` table, which serves as a central
129129
repository for preserving and managing these crucial access control details."""
130130
toolkit = GroupMigrationToolkit(cfg)
131-
toolkit.prepare_environment()
132131
toolkit.cleanup_inventory_table()
133132
toolkit.inventorize_permissions()
134133

135134

136-
@task("assessment", depends_on=[crawl_tables, crawl_grants, inventorize_permissions], dashboard="assessment")
135+
@task(
136+
"assessment",
137+
depends_on=[crawl_grants, crawl_permissions, guess_external_locations, assess_jobs, assess_clusters],
138+
dashboard="assessment",
139+
)
137140
def assessment_report(_: MigrationConfig):
138141
"""This meticulously prepared report serves the purpose of evaluating and gauging the preparedness of a specific
139142
workspace for a smooth transition to the Unity Catalog.
@@ -155,7 +158,7 @@ def assessment_report(_: MigrationConfig):
155158
way for a new era of excellence in data management."""
156159

157160

158-
@task("migrate-groups", depends_on=[inventorize_permissions])
161+
@task("migrate-groups", depends_on=[crawl_permissions])
159162
def migrate_permissions(cfg: MigrationConfig):
160163
"""As we embark on the complex journey of migrating from Hive Metastore to the Databricks Unity Catalog,
161164
a crucial phase in this transition involves the careful management of permissions.
@@ -193,6 +196,12 @@ def delete_backup_groups(cfg: MigrationConfig):
193196
toolkit.delete_backup_groups()
194197

195198

199+
@task("destroy-schema")
200+
def destroy_schema(cfg: MigrationConfig):
201+
"""Removes the `$inventory` database"""
202+
RuntimeBackend().execute(f"DROP DATABASE {cfg.inventory_database} CASCADE")
203+
204+
196205
def main():
197206
trigger(*sys.argv)
198207

src/databricks/labs/ucx/workspace_access/listing.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
from databricks.sdk.core import DatabricksError
99
from databricks.sdk.service.workspace import ObjectInfo, ObjectType
1010

11-
from databricks.labs.ucx.mixins.hardening import rate_limited
12-
1311
logger = logging.getLogger(__name__)
1412

1513

@@ -42,7 +40,6 @@ def _progress_report(self, _):
4240
f" rps: {rps:.3f}/sec"
4341
)
4442

45-
@rate_limited(max_requests=45) # safety value, can be 50 actually
4643
def _list_workspace(self, path: str) -> Iterator[ObjectType]:
4744
# TODO: remove, use SDK
4845
return self._ws.workspace.list(path=path, recursive=False)

tests/unit/assessment/test_assessment.py

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

66
from databricks.labs.ucx.assessment.crawlers import ClustersCrawler, JobsCrawler
77
from databricks.labs.ucx.hive_metastore.data_objects import ExternalLocationCrawler
8-
from databricks.labs.ucx.hive_metastore.list_mounts import Mount
8+
from databricks.labs.ucx.hive_metastore.mounts import Mount
99
from databricks.labs.ucx.mixins.sql import Row
1010
from tests.unit.framework.mocks import MockBackend
1111

tests/unit/hive_metastore/test_mounts.py

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

33
from databricks.sdk.dbutils import MountInfo
44

5-
from databricks.labs.ucx.hive_metastore.list_mounts import Mount, Mounts
5+
from databricks.labs.ucx.hive_metastore.mounts import Mount, Mounts
66
from tests.unit.framework.mocks import MockBackend
77

88

0 commit comments

Comments
 (0)