Skip to content

Commit

Permalink
Merge branch 'main' of github.com:modal-labs/modal-client into luis/a…
Browse files Browse the repository at this point in the history
…dd-proxies-to-sandboxes
  • Loading branch information
luiscape committed Nov 27, 2024
2 parents b861a9e + 04ce2fa commit c6ce03c
Show file tree
Hide file tree
Showing 38 changed files with 679 additions and 528 deletions.
98 changes: 49 additions & 49 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,51 @@ env:
PYTHONIOENCODING: utf-8

jobs:

client-versioning:
if: github.ref == 'refs/heads/main'
name: Update changelog and client version
concurrency: client-versioning
runs-on: ubuntu-20.04
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
client-version: ${{ steps.version.outputs.client_version }}

steps:
- name: Generate token for Github PR Bot
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.GH_PRBOT_APP_ID }}
private_key: ${{ secrets.GH_PRBOT_APP_PRIVATE_KEY }}

- uses: actions/checkout@v3
with:
token: ${{ steps.generate_token.outputs.token }}

- uses: ./.github/actions/setup-cached-python
with:
version: "3.10"

- name: Bump the version number
run: inv update-build-number

- name: Update the changelog
run: inv update-changelog --sha=$GITHUB_SHA

- name: Get the current client version
id: version
run: echo "client_version=`python -m modal_version`" >> "$GITHUB_OUTPUT"

- uses: EndBug/add-and-commit@v9
with:
add: modal_version/_version_generated.py CHANGELOG.md
tag: v${{ steps.version.outputs.client_version }}
message: "[auto-commit] [skip ci] Bump the build number"
pull: "--rebase --autostash"
default_author: github_actions

client-test:
name: Unit tests on ${{ matrix.python-version }} and ${{ matrix.os }} (protobuf=${{ matrix.proto-version }})
timeout-minutes: 30
Expand Down Expand Up @@ -63,8 +108,7 @@ jobs:
run: pytest -v

- name: Run docstring tests
# TODO(michael) disable doctests on 3.13 until workspace is updated to new Image Builder Version
if: github.event.pull_request.head.repo.fork == 'false' && matrix.python-version != '3.13'
if: github.event.pull_request.head.repo.fork == false
env:
MODAL_ENVIRONMENT: client-doc-tests
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
Expand Down Expand Up @@ -161,48 +205,20 @@ jobs:
publish-client:
name: Publish client package
if: github.ref == 'refs/heads/main'
needs: [client-test]
needs: [client-versioning, client-test]
runs-on: ubuntu-20.04
concurrency: publish-client
timeout-minutes: 5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Generate token for Github PR Bot
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.GH_PRBOT_APP_ID }}
private_key: ${{ secrets.GH_PRBOT_APP_PRIVATE_KEY }}

- uses: actions/checkout@v3
with:
token: ${{ steps.generate_token.outputs.token }}
ref: main
fetch-depth: 10 # Fetch multiple commits to find the right changelog entry with concurrent deployments
ref: v${{ needs.client-versioning.outputs.client-version}}

- uses: ./.github/actions/setup-cached-python
with:
version: "3.10"

- name: Bump the version number
run: inv update-build-number

- name: Update the changelog
run: inv update-changelog --sha=$GITHUB_SHA

- name: Get the current client version
id: version
run: echo "client_version=`python -m modal_version`" >> "$GITHUB_OUTPUT"

- uses: EndBug/add-and-commit@v9
with:
add: modal_version/_version_generated.py CHANGELOG.md
tag: v${{ steps.version.outputs.client_version }}
message: "[auto-commit] [skip ci] Bump the build number"
pull: "--rebase --autostash"
default_author: github_actions

- name: Build protobuf
run: inv protoc

Expand All @@ -215,18 +231,9 @@ jobs:
- name: Build wheel
run: python setup.py bdist_wheel

- name: Create alias package
run: inv create-alias-package

- name: Build alias package
working-directory: alias-package
run: python setup.py bdist_wheel

- name: Set the Modal environment
run: modal config set-environment main

- name: Publish client mount
env:
MODAL_ENVIRONMENT: main
MODAL_LOGLEVEL: DEBUG
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
Expand All @@ -237,10 +244,3 @@ jobs:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: twine upload dist/* --non-interactive

- name: Upload alias package to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
working-directory: alias-package
run: twine upload dist/* --non-interactive
33 changes: 0 additions & 33 deletions .github/workflows/pr-autoapprove.yml

This file was deleted.

71 changes: 0 additions & 71 deletions .github/workflows/pr_autoapprove.py

This file was deleted.

24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@ We appreciate your patience while we speedily work towards a stable release of t

<!-- NEW CONTENT GENERATED BELOW. PLEASE PRESERVE THIS COMMENT. -->

### 0.66.49 (2024-11-26)

- `modal config set-environment` will now raise if the requested environment does not exist.



### 0.66.45 (2024-11-26)

- The `modal launch` CLI now accepts a `--detach` flag to run the App in detached mode, such that it will persist after the local client disconnects.



### 0.66.40 (2024-11-23)

* Adds `Image.add_local_file(..., copy=False)` and `Image.add_local_dir(..., copy=False)` as a unified replacement for the old `Image.copy_local_*()` and `Mount.add_local_*` methods.



### 0.66.30 (2024-11-21)

- Removed the `aiostream` package from the modal client library dependencies.



### 0.66.29 (2024-11-21)

* Adds `Image.add_local_python_packages` which works similarly to `Mount.from_local_python_packages` but for images.
Expand Down
2 changes: 1 addition & 1 deletion modal/_container_entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def main(container_args: api_pb2.ContainerArguments, client: Client):
call_lifecycle_functions(event_loop, container_io_manager, list(pre_snapshot_methods.values()))

# If this container is being used to create a checkpoint, checkpoint the container after
# global imports and innitialization. Checkpointed containers run from this point onwards.
# global imports and initialization. Checkpointed containers run from this point onwards.
if is_snapshotting_function:
container_io_manager.memory_snapshot()

Expand Down
9 changes: 7 additions & 2 deletions modal/_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,14 @@ async def loader():
raise NotFoundError(exc.message)
raise

# Check that the id of functions and classes didn't change
# Check that the id of functions didn't change
# Persisted refs are ignored because their life cycle is managed independently.
if not obj._is_another_app and existing_object_id is not None and obj.object_id != existing_object_id:
if (
not obj._is_another_app
and existing_object_id is not None
and existing_object_id.startswith("fu-")
and obj.object_id != existing_object_id
):
raise Exception(
f"Tried creating an object using existing id {existing_object_id}"
f" but it has id {obj.object_id}"
Expand Down
2 changes: 1 addition & 1 deletion modal/_runtime/user_code_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def get_user_class_instance(
modal_obj: modal.cls.Obj = cls(*args, **kwargs)
modal_obj.entered = True # ugly but prevents .local() from triggering additional enter-logic
# TODO: unify lifecycle logic between .local() and container_entrypoint
user_cls_instance = modal_obj._get_user_cls_instance()
user_cls_instance = modal_obj._cached_user_cls_instance()
else:
# undecorated class (non-global decoration or serialized)
user_cls_instance = cls(*args, **kwargs)
Expand Down
36 changes: 28 additions & 8 deletions modal/_utils/function_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,16 @@ async def _create_input(
)


def _get_suffix_from_web_url_info(url_info: api_pb2.WebUrlInfo) -> str:
if url_info.truncated:
suffix = " [grey70](label truncated)[/grey70]"
elif url_info.label_stolen:
suffix = " [grey70](label stolen)[/grey70]"
else:
suffix = ""
return suffix


class FunctionCreationStatus:
# TODO(michael) this really belongs with other output-related code
# but moving it here so we can use it when loading a function with output disabled
Expand Down Expand Up @@ -547,12 +557,7 @@ def __exit__(self, exc_type, exc_val, exc_tb):
elif self.response.function.web_url:
url_info = self.response.function.web_url_info
# Ensure terms used here match terms used in modal.com/docs/guide/webhook-urls doc.
if url_info.truncated:
suffix = " [grey70](label truncated)[/grey70]"
elif url_info.label_stolen:
suffix = " [grey70](label stolen)[/grey70]"
else:
suffix = ""
suffix = _get_suffix_from_web_url_info(url_info)
# TODO: this is only printed when we're showing progress. Maybe move this somewhere else.
web_url = self.response.handle_metadata.web_url
self.status_row.finish(
Expand All @@ -563,8 +568,23 @@ def __exit__(self, exc_type, exc_val, exc_tb):
for custom_domain in self.response.function.custom_domain_info:
custom_domain_status_row = self.resolver.add_status_row()
custom_domain_status_row.finish(
f"Custom domain for {self.tag} => [magenta underline]"
f"{custom_domain.url}[/magenta underline]{suffix}"
f"Custom domain for {self.tag} => [magenta underline]" f"{custom_domain.url}[/magenta underline]"
)
else:
self.status_row.finish(f"Created function {self.tag}.")
if self.response.function.method_definitions_set:
for method_definition in self.response.function.method_definitions.values():
if method_definition.web_url:
url_info = method_definition.web_url_info
suffix = _get_suffix_from_web_url_info(url_info)
class_web_endpoint_method_status_row = self.resolver.add_status_row()
class_web_endpoint_method_status_row.finish(
f"Created web endpoint for {method_definition.function_name} => [magenta underline]"
f"{method_definition.web_url}[/magenta underline]{suffix}"
)
for custom_domain in method_definition.custom_domain_info:
custom_domain_status_row = self.resolver.add_status_row()
custom_domain_status_row.finish(
f"Custom domain for {method_definition.function_name} => [magenta underline]"
f"{custom_domain.url}[/magenta underline]"
)
Loading

0 comments on commit c6ce03c

Please sign in to comment.