Skip to content

Commit 6669a60

Browse files
Update _helper_functions.py
Added resolve_dataflow_name_and_id to return dataflow name and ID information.
1 parent b7fe412 commit 6669a60

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/sempy_labs/_helper_functions.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,43 @@ def resolve_dataset_name(dataset_id: UUID, workspace: Optional[str] = None) -> s
209209
return obj
210210

211211

212+
def resolve_dataflow_name_and_id(dataflow: str, workspace: Optional[str] = None) -> Tuple[str, str]:
213+
"""
214+
Obtains the name and ID of the dataflow.
215+
216+
Parameters
217+
----------
218+
dataflow : str
219+
The name of the dataflow.
220+
workspace : str, default=None
221+
The Fabric workspace name.
222+
Defaults to None which resolves to the workspace of the attached lakehouse
223+
or if no lakehouse attached, resolves to the workspace of the notebook.
224+
225+
Returns
226+
-------
227+
Tuple[str, str]
228+
The dataflow name and ID.
229+
"""
230+
231+
if workspace is None:
232+
workspace_id = fabric.get_workspace_id()
233+
workspace = fabric.resolve_workspace_name(workspace_id)
234+
else:
235+
workspace, workspace_id = resolve_workspace_name_and_id(workspace)
236+
237+
dataflows = list_dataflows(workspace)
238+
filtered_dataflows = dataflows[(dataflows["Dataflow Name"].str.lower() == dataflow.lower()) | (dataflows["Dataflow Id"] == dataflow)]
239+
240+
if filtered_dataflows.empty:
241+
return "", ""
242+
243+
dataflow = filtered_dataflows["Dataflow Name"].iloc[0]
244+
dataflow_id = filtered_dataflows["Dataflow Id"].iloc[0]
245+
246+
return str(dataflow), str(dataflow_id)
247+
248+
212249
def resolve_lakehouse_name(
213250
lakehouse_id: Optional[UUID] = None, workspace: Optional[str] = None
214251
) -> str:

0 commit comments

Comments
 (0)