Skip to content

Commit 1b33d5c

Browse files
committed
Use set for membership test
1 parent a8d1fa2 commit 1b33d5c

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/databricks/labs/ucx/assessment/workflows.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ def crawl_tables(self, ctx: RuntimeContext):
2121
`$inventory_database.tables`. Note that the `inventory_database` is set in the configuration file. The metadata
2222
stored is then used in the subsequent tasks and workflows to, for example, find all Hive Metastore tables that
2323
cannot easily be migrated to Unity Catalog."""
24-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
24+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
2525
ctx.tables_crawler.snapshot(force_refresh=force_refresh)
2626

2727
@job_task
2828
def crawl_udfs(self, ctx: RuntimeContext):
2929
"""Iterates over all UDFs in the Hive Metastore of the current workspace and persists their metadata in the
3030
table named `$inventory_database.udfs`. This inventory is currently used when scanning securable objects for
3131
issues with grants that cannot be migrated to Unit Catalog."""
32-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
32+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
3333
ctx.udfs_crawler.snapshot(force_refresh=force_refresh)
3434

3535
@job_task(job_cluster="tacl")
@@ -45,7 +45,7 @@ def crawl_grants(self, ctx: RuntimeContext):
4545
4646
Note: This job runs on a separate cluster (named `tacl`) as it requires the proper configuration to have the Table
4747
ACLs enabled and available for retrieval."""
48-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
48+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
4949
ctx.grants_crawler.snapshot(force_refresh=force_refresh)
5050

5151
@job_task(depends_on=[crawl_tables])
@@ -54,7 +54,7 @@ def estimate_table_size_for_migration(self, ctx: RuntimeContext):
5454
"synced". These tables will have to be cloned in the migration process.
5555
Assesses the size of these tables and create `$inventory_database.table_size` table to list these sizes.
5656
The table size is a factor in deciding whether to clone these tables."""
57-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
57+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
5858
ctx.table_size_crawler.snapshot(force_refresh=force_refresh)
5959

6060
@job_task
@@ -65,7 +65,7 @@ def crawl_mounts(self, ctx: RuntimeContext):
6565
6666
The assessment involves scanning the workspace to compile a list of all existing mount points and subsequently
6767
storing this information in the `$inventory.mounts` table. This is crucial for planning the migration."""
68-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
68+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
6969
ctx.mounts_crawler.snapshot(force_refresh=force_refresh)
7070

7171
@job_task(depends_on=[crawl_mounts, crawl_tables])
@@ -78,7 +78,7 @@ def guess_external_locations(self, ctx: RuntimeContext):
7878
- Extracting all the locations associated with tables that do not use DBFS directly, but a mount point instead
7979
- Scanning all these locations to identify folders that can act as shared path prefixes
8080
- These identified external locations will be created subsequently prior to the actual table migration"""
81-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
81+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
8282
ctx.external_locations.snapshot(force_refresh=force_refresh)
8383

8484
@job_task
@@ -92,7 +92,7 @@ def assess_jobs(self, ctx: RuntimeContext):
9292
- Clusters with incompatible Spark config tags
9393
- Clusters referencing DBFS locations in one or more config options
9494
"""
95-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
95+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
9696
ctx.jobs_crawler.snapshot(force_refresh=force_refresh)
9797

9898
@job_task
@@ -106,7 +106,7 @@ def assess_clusters(self, ctx: RuntimeContext):
106106
- Clusters with incompatible spark config tags
107107
- Clusters referencing DBFS locations in one or more config options
108108
"""
109-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
109+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
110110
ctx.clusters_crawler.snapshot(force_refresh=force_refresh)
111111

112112
@job_task
@@ -120,7 +120,7 @@ def assess_pipelines(self, ctx: RuntimeContext):
120120
121121
Subsequently, a list of all the pipelines with matching configurations are stored in the
122122
`$inventory.pipelines` table."""
123-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
123+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
124124
ctx.pipelines_crawler.snapshot(force_refresh=force_refresh)
125125

126126
@job_task
@@ -134,7 +134,7 @@ def assess_incompatible_submit_runs(self, ctx: RuntimeContext):
134134
It also combines several submit runs under a single pseudo_id based on hash of the submit run configuration.
135135
Subsequently, a list of all the incompatible runs with failures are stored in the
136136
`$inventory.submit_runs` table."""
137-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
137+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
138138
ctx.submit_runs_crawler.snapshot(force_refresh=force_refresh)
139139

140140
@job_task
@@ -146,7 +146,7 @@ def crawl_cluster_policies(self, ctx: RuntimeContext):
146146
147147
Subsequently, a list of all the policies with matching configurations are stored in the
148148
`$inventory.policies` table."""
149-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
149+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
150150
ctx.policies_crawler.snapshot(force_refresh=force_refresh)
151151

152152
@job_task(cloud="azure")
@@ -161,7 +161,7 @@ def assess_azure_service_principals(self, ctx: RuntimeContext):
161161
Subsequently, the list of all the Azure Service Principals referred in those configurations are saved
162162
in the `$inventory.azure_service_principals` table."""
163163
if ctx.is_azure:
164-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
164+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
165165
ctx.azure_service_principal_crawler.snapshot(force_refresh=force_refresh)
166166

167167
@job_task
@@ -171,7 +171,7 @@ def assess_global_init_scripts(self, ctx: RuntimeContext):
171171
172172
It looks in:
173173
- the list of all the global init scripts are saved in the `$inventory.global_init_scripts` table."""
174-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
174+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
175175
ctx.global_init_scripts_crawler.snapshot(force_refresh=force_refresh)
176176

177177
@job_task
@@ -184,7 +184,7 @@ def workspace_listing(self, ctx: RuntimeContext):
184184
if not ctx.config.use_legacy_permission_migration:
185185
logger.info("Skipping workspace listing as legacy permission migration is disabled.")
186186
return
187-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
187+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
188188
ctx.workspace_listing.snapshot(force_refresh=force_refresh)
189189

190190
@job_task(depends_on=[crawl_grants, workspace_listing])
@@ -199,25 +199,25 @@ def crawl_permissions(self, ctx: RuntimeContext):
199199
return
200200
permission_manager = ctx.permission_manager
201201
permission_manager.reset()
202-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
202+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
203203
permission_manager.snapshot(force_refresh=force_refresh)
204204

205205
@job_task
206206
def crawl_groups(self, ctx: RuntimeContext):
207207
"""Scans all groups for the local group migration scope"""
208-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
208+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
209209
ctx.group_manager.snapshot(force_refresh=force_refresh)
210210

211211
@job_task
212212
def crawl_redash_dashboards(self, ctx: RuntimeContext):
213213
"""Scans all Redash dashboards."""
214-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
214+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
215215
ctx.redash_crawler.snapshot(force_refresh=force_refresh)
216216

217217
@job_task
218218
def crawl_lakeview_dashboards(self, ctx: RuntimeContext):
219219
"""Scans all Lakeview dashboards."""
220-
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in ["true", "1"]
220+
force_refresh = ctx.named_parameters.get("force_refresh", "False").lower() in {"true", "1"}
221221
ctx.lakeview_crawler.snapshot(force_refresh=force_refresh)
222222

223223
@job_task(depends_on=[crawl_redash_dashboards, crawl_lakeview_dashboards])

0 commit comments

Comments
 (0)