Repository navigation
fix(windows): support artifact uploads, PyPI installation, and VS Code IDE detection on Windows #218
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
dborowitz
wants to merge
6
commits into
dborowitz-ci-and-repo-modernization
Choose a base branch
from
dborowitz-cross-platform-ci
base: dborowitz-ci-and-repo-modernization
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix(windows): support artifact uploads, PyPI installation, and VS Code IDE detection on Windows #218
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
314d06c
ci: run unit and integration tests on macOS and Windows with stockout…
dborowitz 23125f8
fix(windows): use UUID for PyPiArtifacts temp filenames and fix cross…
dborowitz a8c0793
fix(windows): convert Windows drive-letter artifact paths to file:// …
dborowitz 4a9f9c2
fix(windows): normalize PyPI config artifact path and alias addArtifact
dborowitz 48a0e27
test: skip POSIX-only IDE tests on Windows and use get_session_contro…
dborowitz 98772dc
fix(windows): support InnoSetup commit-subdir VS Code layout and add …
dborowitz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
| import json | ||
| import logging | ||
| import os | ||
| import pathlib | ||
| import random | ||
| import re | ||
| import string | ||
|
|
@@ -231,6 +232,25 @@ def _is_valid_label_value(value: str) -> bool: | |
| return bool(re.match(pattern, value)) | ||
|
|
||
|
|
||
| def _normalize_artifact_path(path_or_uri: str) -> str: | ||
| """Convert Windows drive-letter paths (e.g. C:\\...) to file:// URIs. | ||
|
|
||
| PySpark's ArtifactManager._parse_artifacts uses urllib.parse.urlparse(), | ||
| which misinterprets a Windows drive letter like 'C:\\...' as URL scheme 'c' | ||
| and raises '[UNSUPPORTED_OPERATION] c scheme is not supported'. | ||
| """ | ||
| if ( | ||
| len(path_or_uri) >= 3 | ||
| and path_or_uri[0].isalpha() | ||
| and path_or_uri[1] == ":" | ||
| and path_or_uri[2] in ("\\", "/") | ||
| ): | ||
| path_part, sep, fragment = path_or_uri.partition("#") | ||
| uri = pathlib.PureWindowsPath(path_part).as_uri() | ||
| return f"{uri}#{fragment}" if sep else uri | ||
| return path_or_uri | ||
|
|
||
|
|
||
| def _is_valid_session_id(session_id: str) -> bool: | ||
| """ | ||
| Validates if a string complies with Google Cloud session ID format. | ||
|
|
@@ -1517,14 +1537,23 @@ def addArtifacts( | |
| artifacts = PyPiArtifacts(set(artifact)) | ||
| logger.debug("Making addArtifact call to install packages") | ||
| self.addArtifact( | ||
| artifacts.write_packages_config(self._active_s8s_session_uuid), | ||
| _normalize_artifact_path( | ||
| artifacts.write_packages_config( | ||
| self._active_s8s_session_uuid | ||
| ) | ||
| ), | ||
| file=True, | ||
| ) | ||
|
Comment on lines
1537
to
1546
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If if not self._active_s8s_session_uuid:
raise ManagedSparkConnectException(
"Cannot add PyPI artifacts: no active Managed Spark session."
)
artifacts = PyPiArtifacts(set(artifact))
logger.debug("Making addArtifact call to install packages")
self.addArtifact(
_normalize_artifact_path(
artifacts.write_packages_config(
self._active_s8s_session_uuid
)
),
file=True,
) |
||
| else: | ||
| super().addArtifacts( | ||
| *artifact, pyfile=pyfile, archive=archive, file=file | ||
| *(_normalize_artifact_path(p) for p in artifact), | ||
| pyfile=pyfile, | ||
| archive=archive, | ||
| file=file, | ||
| ) | ||
|
|
||
| addArtifact = addArtifacts | ||
|
|
||
| @staticmethod | ||
| def _get_active_session_file_path(): | ||
| return os.getenv("MANAGED_SPARK_CONNECT_ACTIVE_SESSION_FILE_PATH") | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
os.scandirwithout a context manager can lead to unclosed directory handles, which is particularly problematic on Windows where file/directory locking is strict. Additionally, we can filter for directories and hex commit prefixes during the scan to avoid sorting non-matching entries, improving both safety and performance.