-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add arm64 platform support to dagster-cloud.pex, do the build inside a manylinux builder image #206
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Binary file not shown.
This file contains 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Builds generated/gha/dagster-cloud.pex and writes it to /generated | ||
|
||
# Use an official manylinux builder (https://github.com/pypa/manylinux#docker-images) | ||
FROM --platform=linux/amd64 quay.io/pypa/manylinux_2_28_x86_64:latest | ||
|
||
ENV PATH="/opt/python/cp311-cp311/bin:$PATH" | ||
|
||
RUN python3.11 -m pip install typer rich pex | ||
|
||
COPY release.py release.py | ||
|
||
RUN mkdir -p /generated | ||
|
||
CMD ["python3.11", "release.py", "build-dagster-cloud-pex"] |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Used for testing the generated dagster-cloud pex | ||
FROM --platform=linux/amd64 python:3.10-slim | ||
|
||
COPY generated/gha/dagster-cloud.pex /dagster-cloud.pex | ||
|
||
ENTRYPOINT ["/dagster-cloud.pex"] |
This file contains 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 |
---|---|---|
@@ -1,62 +1,91 @@ | ||
import os | ||
import subprocess | ||
import tempfile | ||
from contextlib import contextmanager | ||
from typing import List | ||
from typing import List, Mapping | ||
|
||
import pytest | ||
|
||
|
||
def run_dagster_cloud_serverless_cmd(args: List[str], map_folders: Mapping[str, str]): | ||
mount_args = [] | ||
for target_folder, source_folder in map_folders.items(): | ||
mount_args.extend(["--mount", f"type=bind,source={source_folder},target={target_folder}"]) | ||
|
||
cmd = [ | ||
"docker", | ||
"run", | ||
"--platform=linux/amd64", | ||
*mount_args, | ||
"-t", | ||
"test-dagster-cloud-pex", | ||
"-m", | ||
"dagster_cloud_cli.entrypoint", | ||
"serverless", | ||
*args, | ||
] | ||
|
||
subprocess.run(cmd, encoding="utf-8", capture_output=False, check=True) | ||
|
||
|
||
@pytest.fixture | ||
def built_test_dagster_cloud_pex_image(repo_root: str): | ||
src_dir = os.path.join(os.path.dirname(__file__), "..", "src") | ||
|
||
cmd = [ | ||
"docker", | ||
"build", | ||
"--progress=plain", | ||
"-t", | ||
"test-dagster-cloud-pex", | ||
"--platform=linux/amd64", | ||
"-f", | ||
os.path.join(src_dir, "Dockerfile.test-dagster-cloud-pex"), | ||
repo_root, | ||
] | ||
|
||
subprocess.run(cmd, check=True) | ||
|
||
|
||
def test_pex_build_only(repo_root, built_test_dagster_cloud_pex_image): | ||
dagster_project1 = repo_root / "tests/test-repos/dagster_project1" | ||
|
||
@contextmanager | ||
def run_dagster_cloud_serverless_cmd(dagster_cloud_pex_path, args: List[str]): | ||
with tempfile.TemporaryDirectory() as build_output_dir: | ||
proc = subprocess.run( | ||
map_folders = {"/dagster_project1": dagster_project1, "/build_output_dir": build_output_dir} | ||
|
||
run_dagster_cloud_serverless_cmd( | ||
[ | ||
dagster_cloud_pex_path, | ||
"-m", | ||
"dagster_cloud_cli.entrypoint", | ||
"serverless", | ||
*args, | ||
build_output_dir, | ||
"build-python-executable", | ||
"/dagster_project1", | ||
"--api-token=fake", | ||
"--url=fake", | ||
"--python-version=3.10", | ||
"/build_output_dir", | ||
], | ||
capture_output=True, | ||
check=False, | ||
map_folders=map_folders, | ||
) | ||
if proc.returncode: | ||
raise ValueError( | ||
"Failed to run dagster-cloud.pex:" + (proc.stdout + proc.stderr).decode("utf-8") | ||
) | ||
|
||
all_files = os.listdir(build_output_dir) | ||
pex_files = { | ||
filename for filename in all_files if filename.endswith(".pex") and filename != ".pex" | ||
} | ||
yield (build_output_dir, list(pex_files), list(set(all_files) - pex_files)) | ||
|
||
|
||
def test_pex_build_only(repo_root, dagster_cloud_pex_path): | ||
dagster_project1 = repo_root / "tests/test-repos/dagster_project1" | ||
with run_dagster_cloud_serverless_cmd( | ||
dagster_cloud_pex_path, | ||
[ | ||
"build-python-executable", | ||
str(dagster_project1), | ||
"--api-token=fake", | ||
"--url=fake", | ||
"--python-version=3.11", | ||
], | ||
) as ( | ||
build_output_dir, | ||
pex_files, | ||
other_files, | ||
): | ||
# one source-HASH.pex and one deps-HASH.pex file are expected | ||
assert 2 == len(pex_files) | ||
pex_file_by_alias = {filename.split("-", 1)[0]: filename for filename in pex_files} | ||
|
||
assert {"source", "deps"} == set(pex_file_by_alias) | ||
|
||
|
||
def test_dagster_cloud_runnable(dagster_cloud_pex_path): | ||
output = subprocess.check_output( | ||
[dagster_cloud_pex_path, "-c", "print('hello')"], encoding="utf-8" | ||
) | ||
assert "hello" in output | ||
def test_dagster_cloud_runnable(built_test_dagster_cloud_pex_image): | ||
cmd = [ | ||
"docker", | ||
"run", | ||
"--platform=linux/amd64", | ||
"-t", | ||
"test-dagster-cloud-pex", | ||
"-c", | ||
"print('hello')", | ||
] | ||
output = subprocess.run(cmd, encoding="utf-8", capture_output=True, check=True) | ||
|
||
assert "hello" in output.stdout |
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.
i had to take these out to keep us below 100MB :/ is there a reason to keep them other than passing the local tests? I wouldn't expect anybody to actually be running this pex in a mac OS context since it's for github actions
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.
(well, they do have macOS github runners, but it would be very surprising if people were using them for this purpose)
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.
updated the PR to run the tests in docker images
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.
no other reason. i'm ok with removing.