Skip to content

Update _git.py - added param to initialize_git_connection fn #490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/sempy_labs/_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def get_git_connection(workspace: Optional[str | UUID] = None) -> pd.DataFrame:
return df


def initialize_git_connection(workspace: Optional[str | UUID] = None) -> str:
def initialize_git_connection(workspace: Optional[str | UUID] = None, initialization_strategy: Optional[str] = 'None') -> str:
"""
Initializes a connection for a workspace that is connected to Git.

Expand All @@ -276,6 +276,11 @@ def initialize_git_connection(workspace: Optional[str | UUID] = None) -> str:
The Fabric workspace name or ID.
Defaults to None which resolves to the workspace of the attached lakehouse
or if no lakehouse attached, resolves to the workspace of the notebook.
initialization_strategy : str
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initialization_strategy : str, default='None'

Defines the strategy required for an initialization process when content
exists on both the remote side and the workspace side.
Additional strategies may be added over time.
Supported options: PreferWorkspace, PreferRemote or None (default)

Returns
-------
Expand All @@ -285,8 +290,14 @@ def initialize_git_connection(workspace: Optional[str | UUID] = None) -> str:

(workspace_name, workspace_id) = resolve_workspace_name_and_id(workspace)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a check that the initialization_strategy is one of the 3 valid options. raise ValueError if it's not in those 3 options. This is just to make better error messages.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a helpful note for @hurtn: You can look at how conflict_resolution_policy is validated in the update_from_git function within the same file. If you want to do it consistent in the same style and so on.


payload = {
"initializationStrategy": initialization_strategy
}

response_json = _base_api(
request=f"/v1/workspaces/{workspace_id}/git/initializeConnection",
payload=payload,
method="post",
lro_return_json=True,
status_codes=None,
Expand Down