Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thesayyn committed Oct 4, 2024
1 parent 9252e7d commit 7880085
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 69 deletions.
5 changes: 1 addition & 4 deletions docs/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ stardoc_with_diff_test(

stardoc_with_diff_test(
name = "py_image_layer",
bzl_library_target = "//py:defs",
symbol_names = [
"py_image_layer",
],
bzl_library_target = "//py/private:py_image_layer",
)

stardoc_with_diff_test(
Expand Down
69 changes: 23 additions & 46 deletions docs/py_image_layer.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 31 additions & 19 deletions py/private/py_image_layer.bzl
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
"py_image_layer"
"""py_image_layer macro for creating multiple layers from a py_binary
>> [!WARNING]
>> This macro is EXPERIMENTAL and is not subject to our SemVer guarantees.
A py_binary that uses `torch` and `numpy` can use the following layer groups:
```
load("@rules_oci//oci:defs.bzl", "oci_image")
load("@aspect_rules_py//py:defs.bzl", "py_image_layer", "py_binary")
py_binary(
name = "my_app_bin",
deps = [
"@pip_deps//numpy",
"@pip_deps//torch"
]
)
oci_image(
tars = py_image_layer(
name = "my_app",
py_binary = ":my_app_bin",
layer_groups = {
"torch": "pip_deps_torch.*",
"numpy": "pip_deps_numpy.*",
}
)
)
```
"""

load("@aspect_bazel_lib//lib:tar.bzl", "mtree_spec", "tar")

Expand Down Expand Up @@ -63,8 +93,6 @@ awk < $< 'BEGIN {
def py_image_layer(name, py_binary, root = None, layer_groups = {}, compress = "gzip", tar_args = ["--options", "gzip:!timestamp"], **kwargs):
"""Produce a separate tar output for each layer of a python app
> Note: This macro is EXPERIMENTAL and is not subject to our SemVer guarantees.
> Requires `awk` to be installed on the host machine/rbe runner.
For better performance, it is recommended to split the output of a py_binary into multiple layers.
Expand All @@ -83,22 +111,6 @@ def py_image_layer(name, py_binary, root = None, layer_groups = {}, compress = "
}
```
A py_binary that uses `torch` and `numpy` can use the following layer groups:
```
oci_image(
tars = py_image_layer(
name = "my_app",
py_binary = ":my_app_bin",
layer_groups = {
"torch": "pip_deps_torch.*",
"numpy": "pip_deps_numpy.*",
}
)
)
```
Args:
name: base name for targets
py_binary: a py_binary target
Expand Down

0 comments on commit 7880085

Please sign in to comment.