From f71114b3f38268e99cb3f7dcb3d8b89c2b8728c0 Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Mon, 5 Jan 2026 01:34:34 -0500 Subject: [PATCH 1/3] feature: make BoundLens Callable --- alpacloud/lens/changelog.md | 13 +++++++++++++ alpacloud/lens/models.py | 7 +++++++ alpacloud/lens/models_test.py | 1 + alpacloud/lens/readme.md | 2 ++ 4 files changed, 23 insertions(+) create mode 100644 alpacloud/lens/changelog.md diff --git a/alpacloud/lens/changelog.md b/alpacloud/lens/changelog.md new file mode 100644 index 0000000..915085f --- /dev/null +++ b/alpacloud/lens/changelog.md @@ -0,0 +1,13 @@ +# 0 + +## 0.2 + +### 0.2.0 + +- feature : make BoundLens Callable + +## 0.1 + +### 0.1.0 + +- release! \ No newline at end of file diff --git a/alpacloud/lens/models.py b/alpacloud/lens/models.py index d43a5d7..9f6af40 100644 --- a/alpacloud/lens/models.py +++ b/alpacloud/lens/models.py @@ -138,6 +138,10 @@ def __mod__(self, other: BoundLensT[S, T, A, B]): def map(self, s: S) -> T: """Modify the focus of this lens.""" + def __call__(self, s: S) -> T: + """Modify the focus of this lens.""" + return self.map(s) + @staticmethod def const(l: LensT[S, T, A, B], v: B) -> BoundLens[S, T, A, B]: """Set the focus of this lens to a constant value.""" @@ -162,6 +166,9 @@ def get(self, s: S) -> A: def map(self, s: S) -> T: return self.lens.l_map(s, self.f) + def __call__(self, s: S) -> T: + return self.lens.l_map(s, self.f) + @dataclass class CombinedBoundLens(BoundLensT[S, S, A, B]): diff --git a/alpacloud/lens/models_test.py b/alpacloud/lens/models_test.py index 372c068..a675a00 100644 --- a/alpacloud/lens/models_test.py +++ b/alpacloud/lens/models_test.py @@ -198,6 +198,7 @@ def test_combined(self): combined = l0 % l1 assert combined.map(v) == [9, 8] + assert combined(v) == [9, 8], "Callable syntax didn't work" def test_combined_coalesce(self): """Test that a CombinedBoundLens will be extended when combined with single items""" diff --git a/alpacloud/lens/readme.md b/alpacloud/lens/readme.md index 9768122..ef56806 100644 --- a/alpacloud/lens/readme.md +++ b/alpacloud/lens/readme.md @@ -34,6 +34,8 @@ You can bind the mapping function to easily apply the same transformation multip # note how we can re-use `replicas` from above add_replica = replicas @ (lambda n: n + 1) add_replica.map(my_deployment) +# or as a Callable +add_replica(my_deployment) ``` You can combine several bound lenses to create pipelines From 76edc8e79014f5a8b0057830e76acecc484e2da0 Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Mon, 5 Jan 2026 01:38:22 -0500 Subject: [PATCH 2/3] task: add py.typed --- alpacloud/argocdkit/BUILD | 4 +++- alpacloud/argocdkit/py.typed | 0 alpacloud/crdvis/BUILD | 4 +++- alpacloud/crdvis/py.typed | 0 alpacloud/eztag/BUILD | 10 ++++++---- alpacloud/eztag/py.typed | 0 alpacloud/lens/BUILD | 4 +++- alpacloud/lens/py.typed | 0 alpacloud/promls/BUILD | 4 +++- alpacloud/promls/changelog.md | 12 ++++++------ alpacloud/promls/py.typed | 0 11 files changed, 24 insertions(+), 14 deletions(-) create mode 100644 alpacloud/argocdkit/py.typed create mode 100644 alpacloud/crdvis/py.typed create mode 100644 alpacloud/eztag/py.typed create mode 100644 alpacloud/lens/py.typed create mode 100644 alpacloud/promls/py.typed diff --git a/alpacloud/argocdkit/BUILD b/alpacloud/argocdkit/BUILD index 9d626aa..9c1d0b1 100644 --- a/alpacloud/argocdkit/BUILD +++ b/alpacloud/argocdkit/BUILD @@ -22,7 +22,7 @@ pex_binary( python_distribution( name="alpacloud.argocdkit", repositories=["@alpacloud.argocdkit"], - dependencies=[":argocdkit"], + dependencies=[":argocdkit", ":py.typed"], long_description_path="alpacloud/argocdkit/readme.md", provides=python_artifact( name="alpacloud.argocdkit", @@ -42,3 +42,5 @@ python_distribution( long_description_content_type="text/markdown", ), ) + +resource(name="py.typed", source="py.typed") diff --git a/alpacloud/argocdkit/py.typed b/alpacloud/argocdkit/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/alpacloud/crdvis/BUILD b/alpacloud/crdvis/BUILD index 802a3ae..6a996b2 100644 --- a/alpacloud/crdvis/BUILD +++ b/alpacloud/crdvis/BUILD @@ -8,7 +8,7 @@ python_tests( python_distribution( name="alpacloud.crdvis", repositories=["@alpacloud.crdvis"], - dependencies=[":crdvis"], + dependencies=[":crdvis", ":py.typed"], long_description_path="alpacloud/crdvis/readme.md", provides=python_artifact( name="alpacloud.crdvis", @@ -29,3 +29,5 @@ python_distribution( long_description_content_type="text/markdown", ), ) + +resource(name="py.typed", source="py.typed") diff --git a/alpacloud/crdvis/py.typed b/alpacloud/crdvis/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/alpacloud/eztag/BUILD b/alpacloud/eztag/BUILD index 2aabcbb..1439fb6 100644 --- a/alpacloud/eztag/BUILD +++ b/alpacloud/eztag/BUILD @@ -5,14 +5,14 @@ python_tests( # dependencies=["./test_resources:k8s_objs"], ) -python_test_utils( - name="test_utils", -) +# python_test_utils( +# name="test_utils", +# ) python_distribution( name="alpacloud.eztag", repositories=["@alpacloud.eztag"], - dependencies=[":eztag"], + dependencies=[":eztag", ":py.typed"], long_description_path="alpacloud/eztag/readme.md", provides=python_artifact( name="alpacloud_eztag", @@ -33,3 +33,5 @@ python_distribution( long_description_content_type="text/markdown", ), ) + +resource(name="py.typed", source="py.typed") diff --git a/alpacloud/eztag/py.typed b/alpacloud/eztag/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/alpacloud/lens/BUILD b/alpacloud/lens/BUILD index a20b5b1..4412543 100644 --- a/alpacloud/lens/BUILD +++ b/alpacloud/lens/BUILD @@ -12,7 +12,7 @@ python_test_utils( python_distribution( name="alpacloud.lens", repositories=["@alpacloud.lens"], - dependencies=[":lens"], + dependencies=[":lens", ":py.typed"], long_description_path="alpacloud/lens/readme.md", provides=python_artifact( name="alpacloud.lens", @@ -32,3 +32,5 @@ python_distribution( long_description_content_type="text/markdown", ), ) + +resource(name="py.typed", source="py.typed") diff --git a/alpacloud/lens/py.typed b/alpacloud/lens/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/alpacloud/promls/BUILD b/alpacloud/promls/BUILD index 57920a7..b928213 100644 --- a/alpacloud/promls/BUILD +++ b/alpacloud/promls/BUILD @@ -10,7 +10,7 @@ python_tests( python_distribution( name="alpacloud.promls", repositories=["@alpacloud.promls"], - dependencies=[":promls"], + dependencies=[":promls", ":py.typed"], long_description_path="alpacloud/promls/readme.md", provides=python_artifact( name="alpacloud_promls", @@ -31,3 +31,5 @@ python_distribution( long_description_content_type="text/markdown", ), ) + +resource(name="py.typed", source="py.typed") diff --git a/alpacloud/promls/changelog.md b/alpacloud/promls/changelog.md index fe4f8b4..b4e17f0 100644 --- a/alpacloud/promls/changelog.md +++ b/alpacloud/promls/changelog.md @@ -1,8 +1,8 @@ # 0 -# 0.3 +## 0.3 -# 0.3.0 +### 0.3.0 - fix : parser can parse escaped sequences - feature : parser can report errors and is more robust @@ -10,14 +10,14 @@ - ui : tweaks for browser tree - feature : combine submetrics of summaries and histograms -# 0.2 +## 0.2 -## 0.2.0 +### 0.2.0 - refactor : drop jank fuzzy finder -# 0.1 +## 0.1 -## 0.1.0 +### 0.1.0 - release \ No newline at end of file diff --git a/alpacloud/promls/py.typed b/alpacloud/promls/py.typed new file mode 100644 index 0000000..e69de29 From e10f326d33b28115ceca713d9a66c3a60836160a Mon Sep 17 00:00:00 2001 From: Daniel Goldman Date: Fri, 27 Feb 2026 11:53:59 -0500 Subject: [PATCH 3/3] task: add an error check for fetching CRD remotely example.com is using a cert that is more modern than the bundle for some pythons includes --- alpacloud/crdvis/crd.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/alpacloud/crdvis/crd.py b/alpacloud/crdvis/crd.py index 8201169..eea0792 100644 --- a/alpacloud/crdvis/crd.py +++ b/alpacloud/crdvis/crd.py @@ -8,6 +8,7 @@ import requests import yaml from pydantic import ValidationError +from requests import RequestException from alpacloud.crdvis.models import CustomResourceDefinition @@ -32,10 +33,13 @@ def read_path(path: str) -> CustomResourceDefinition: if url.netloc == "github.com": req.params["raw"] = "true" - response = requests.Session().send(req.prepare(), timeout=30) + try: + response = requests.Session().send(req.prepare(), timeout=30) + if not response.ok: + raise CRDReadError(f"Failed to fetch CRD from {path}: {response.status_code}") + except RequestException as e: + raise CRDReadError(f"Failed to fetch CRD from {path}: {e}") - if not response.ok: - raise CRDReadError(f"Failed to fetch CRD from {path}: {response.status_code}") content = response.text elif path.startswith("file://") or os.path.exists(path): disk_path = path.rsplit("://", 1)[-1]