Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HariGS-DB committed Jun 18, 2024
1 parent d586022 commit 06d448e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/databricks/labs/blueprint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ def needs_workspace_client(self):
return True

def run_as_collection(self) -> bool:
# A Method can be run as standalone workspace cmd or as a collection. To mark a method as collection method
# we need to add is_collection flag to True
# In addition if the collection_workspace_id is passed then return True else return False
# if collection_workspace_id is passed, the cmd should be run under account client else
# as workspace client.
if not self.is_collection:
return False
sig = inspect.signature(self.fn)
Expand Down Expand Up @@ -111,8 +116,12 @@ def _route(self, raw):
kwargs[kwarg] = float(kwargs[kwarg])
try:
if cmd.needs_workspace_client() and not cmd.run_as_collection():
# if is_account is not set and cmd is either not a collection or
# is a collection but collection_workspace_id not passed
kwargs["w"] = self._workspace_client()
elif cmd.is_account or cmd.run_as_collection():
# if is_account is set or cmd is a collection
# and collection_workspace_id is passed
kwargs["a"] = self._account_client()
prompts_argument = cmd.prompts_argument_name()
if prompts_argument:
Expand Down

0 comments on commit 06d448e

Please sign in to comment.