Skip to content

Commit

Permalink
Create visibility group for examples; rename examples/io->text_io.py;…
Browse files Browse the repository at this point in the history
… fix API visibility of labs
  • Loading branch information
wwwillchen committed Jan 27, 2024
1 parent e16db8a commit 70fc63b
Show file tree
Hide file tree
Showing 28 changed files with 55 additions and 31 deletions.
12 changes: 12 additions & 0 deletions build_defs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,22 @@ load("@rules_python//python:pip.bzl", "compile_pip_requirements")
package_group(
name = "mesop_internal",
packages = [
"-//mesop/examples/...",
"//...",
],
)

# Mesop Example code:
# This is a placeholder where there's an actual allowlist in
# the downstream sync.
package_group(
name = "mesop_examples",
packages = [
"//...",
],
)

# Public API:
# This is a placeholder where there's an actual allowlist in
# the downstream sync.
package_group(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/audio/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/badge/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/box/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/checkbox/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/divider/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/icon/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/image/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/input/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/markdown/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/progress_bar/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/progress_spinner/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/radio/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/select/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/slide_toggle/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/slider/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/text/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/tooltip/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/components/video/e2e/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/examples/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

filegroup(
Expand Down
2 changes: 1 addition & 1 deletion mesop/examples/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
from mesop.examples import generator as generator
from mesop.examples import index as index
from mesop.examples import integrations as integrations
from mesop.examples import io as io
from mesop.examples import nested as nested
from mesop.examples import playground as playground
from mesop.examples import playground_critic as playground_critic
from mesop.examples import readme_app as readme_app
from mesop.examples import simple as simple
from mesop.examples import sxs as sxs
from mesop.examples import testing as testing
from mesop.examples import text_io as text_io

# Do not import error_state_missing_init_prop because it cause all examples to fail.
2 changes: 1 addition & 1 deletion mesop/examples/docs/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/examples/integrations/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/examples/shared/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
2 changes: 1 addition & 1 deletion mesop/examples/testing/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
load("//build_defs:defaults.bzl", "py_library")

package(
default_visibility = ["//build_defs:mesop_internal"],
default_visibility = ["//build_defs:mesop_examples"],
)

py_library(
Expand Down
10 changes: 5 additions & 5 deletions mesop/examples/io.py → mesop/examples/text_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
import mesop.labs as mel


@me.page(path="/text_io")
def app():
mel.text_io(upper_case_stream)


def upper_case(s: str) -> str:
time.sleep(0.5)
return s.capitalize()
Expand All @@ -15,8 +20,3 @@ def upper_case_stream(s: str):
yield s.capitalize() + "foo"
time.sleep(0.5)
yield s.capitalize() + "foo" + "bar"


@me.page(path="/io")
def app():
mel.io(upper_case_stream, input="text", output="text")
14 changes: 13 additions & 1 deletion mesop/labs/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@ package(

py_library(
name = "labs",
srcs = glob(["*.py"]),
srcs = ["__init__.py"],
visibility = ["//build_defs:mesop_users"],
deps = [
":labs_impl",
],
)

py_library(
name = "labs_impl",
srcs = glob(
["*.py"],
exclude = ["__init__.py"],
),
deps = [
"//mesop",
],
Expand Down
2 changes: 1 addition & 1 deletion mesop/labs/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from mesop.labs.io import io as io
from mesop.labs.io import text_io as text_io

0 comments on commit 70fc63b

Please sign in to comment.