Skip to content

Commit

Permalink
Update Dependencies (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsmkn authored Jan 10, 2023
1 parent 9df9670 commit 5820eca
Show file tree
Hide file tree
Showing 6 changed files with 1,073 additions and 941 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Install Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install pre-commit
Expand Down
1,962 changes: 1,028 additions & 934 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ classifiers = [
sagemaker-shim = "sagemaker_shim.cli:cli"

[tool.poetry.dependencies]
# Only support once version of python at a time
# Only support one version of python at a time
python = "^3.10,<3.11"
fastapi = "*"
fastapi = "!=0.89.0"
uvicorn = {extras = ["standard"], version = "*"}
click = "*"
boto3 = "*"
Expand Down
6 changes: 4 additions & 2 deletions tests/test_container_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
get_image_config,
get_new_env_vars,
mutate_image,
pull_image,
push_image,
)

# Tests for compatability with
Expand Down Expand Up @@ -50,7 +52,7 @@ def _container(*, base_image="hello-world:latest", host_port=8080, cmd=None):

# Tag and push it to the local registry
container_image.tag(repo_tag)
client.images.push(repo_tag)
push_image(client=client, repo_tag=repo_tag)

config = get_image_config(repo_tag=repo_tag)
env_vars = get_new_env_vars(existing_config=config)
Expand All @@ -65,7 +67,7 @@ def _container(*, base_image="hello-world:latest", host_port=8080, cmd=None):
env_vars=env_vars,
version=__version__,
)
client.images.pull(new_tag)
pull_image(client=client, repo_tag=new_tag)

container = client.containers.run(
image=new_tag,
Expand Down
9 changes: 7 additions & 2 deletions tests/test_patch_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
import pytest

from tests import __version__
from tests.utils import get_image_config, get_new_env_vars, mutate_image
from tests.utils import (
get_image_config,
get_new_env_vars,
mutate_image,
push_image,
)


@pytest.fixture(autouse=True)
Expand Down Expand Up @@ -50,7 +55,7 @@ def test_patch_image(registry):
repo_tag = f"{repo}/busybox:latest"

client.images.build(fileobj=dockerfile, tag=repo_tag)
client.images.push(repo_tag)
push_image(client=client, repo_tag=repo_tag)

config = get_image_config(repo_tag=repo_tag)
env_vars = get_new_env_vars(existing_config=config)
Expand Down
31 changes: 31 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,37 @@ def encode_b64j(*, val: Any) -> str:
return b64encode(json.dumps(val).encode("utf-8")).decode("utf-8")


def push_image(*, client, repo_tag):
with TemporaryDirectory() as tempdir:
image = client.images.get(name=repo_tag)
image_filename = Path(tempdir) / "image.tar"

f = open(image_filename, "wb")

for chunk in image.save():
f.write(chunk)

f.close()

subprocess.run(
[CRANE_COMMAND, "push", image_filename, repo_tag],
capture_output=True,
)


def pull_image(*, client, repo_tag):
with TemporaryDirectory() as tempdir:
image_filename = Path(tempdir) / "image.tar"

subprocess.run(
[CRANE_COMMAND, "pull", repo_tag, image_filename],
capture_output=True,
)

with open(image_filename, "rb") as f:
client.images.load(data=f)


def get_image_config(*, repo_tag: str) -> Any:
output = subprocess.run(
[CRANE_COMMAND, "config", repo_tag],
Expand Down

0 comments on commit 5820eca

Please sign in to comment.