You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hamilton.apache.org by sk...@apache.org on 2026/06/07 04:39:36 UTC
(hamilton) 03/04: Add tests verifying sdist includes tests and examples
This is an automated email from the ASF dual-hosted git repository.
skrawcz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hamilton.git
commit 1a1973a7e4a1a2a7de122298bcb932adc676c375
Author: Stefan Krawczyk <st...@cs.stanford.edu>
AuthorDate: Sat Jun 6 15:00:08 2026 -0700
Add tests verifying sdist includes tests and examples
Add test_sdist.py for ui/sdk, dev_tools/language_server, and contrib
that assert pyproject.toml [tool.flit.sdist] configuration:
- tests/** is in include (sdk, lsp) or not in exclude (contrib)
- examples/** is in include (sdk, contrib)
- scripts/** is in include (contrib) — addresses reviewer feedback
- Binary files (*.parquet, *.pkl, *.ipynb, *.png) are excluded
Also add test_flit_sdist_includes_tests to ui/backend/tests/test_build.py
to match the existing pattern for build/** verification.
Include contrib/scripts/** in sdist per reviewer request — contains
version_check.py used for release validation.
---
contrib/pyproject.toml | 1 +
contrib/tests/test_sdist.py | 108 +++++++++++++++++++++++++
dev_tools/language_server/tests/test_sdist.py | 62 +++++++++++++++
ui/backend/tests/test_build.py | 17 ++++
ui/sdk/tests/test_sdist.py | 109 ++++++++++++++++++++++++++
5 files changed, 297 insertions(+)
diff --git a/contrib/pyproject.toml b/contrib/pyproject.toml
index 5b3bfbf7..e6880052 100644
--- a/contrib/pyproject.toml
+++ b/contrib/pyproject.toml
@@ -70,6 +70,7 @@ include = [
"DISCLAIMER",
"requirements.txt",
"examples/**",
+ "scripts/**",
]
exclude = [
".git/**",
diff --git a/contrib/tests/test_sdist.py b/contrib/tests/test_sdist.py
new file mode 100644
index 00000000..1ea9d88a
--- /dev/null
+++ b/contrib/tests/test_sdist.py
@@ -0,0 +1,108 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Tests verifying that the sdist includes examples and does not exclude tests.
+
+Per Apache release policy, voters must be able to build from source
+and run tests to validate. Contrib tests live inside the package
+(hamilton/contrib/dagworks/*/test_*.py), so the key requirement is
+that tests/** is NOT in the exclude list. Examples are included via
+a symlink to ../examples/contrib/.
+"""
+
+import sys
+from pathlib import Path
+
+if sys.version_info >= (3, 11):
+ import tomllib
+else:
+ import tomli as tomllib
+
+
+def get_contrib_dir() -> Path:
+ return Path(__file__).resolve().parent.parent
+
+
+def load_sdist_config() -> dict:
+ pyproject = get_contrib_dir() / "pyproject.toml"
+ with open(pyproject, "rb") as f:
+ config = tomllib.load(f)
+ return config["tool"]["flit"]["sdist"]
+
+
+class TestSdistDoesNotExcludeTests:
+ """Verify tests inside the package are not excluded from sdist."""
+
+ def test_tests_not_in_sdist_exclude(self):
+ sdist = load_sdist_config()
+ excludes = sdist.get("exclude", [])
+ assert "tests/**" not in excludes, (
+ "pyproject.toml [tool.flit.sdist] must not exclude 'tests/**'. "
+ "Apache release policy requires tests in the source tarball. "
+ "Contrib tests live inside the package tree."
+ )
+
+
+class TestSdistIncludesExamples:
+ """Verify examples are included in the source distribution."""
+
+ def test_examples_in_sdist_include(self):
+ sdist = load_sdist_config()
+ includes = sdist.get("include", [])
+ assert "examples/**" in includes, (
+ "pyproject.toml [tool.flit.sdist] must include 'examples/**'. "
+ "Examples help voters validate the package works correctly."
+ )
+
+ def test_examples_not_in_sdist_exclude(self):
+ sdist = load_sdist_config()
+ excludes = sdist.get("exclude", [])
+ assert "examples/**" not in excludes, (
+ "pyproject.toml [tool.flit.sdist] must not exclude 'examples/**'."
+ )
+
+
+class TestSdistIncludesScripts:
+ """Verify scripts are included in the source distribution."""
+
+ def test_scripts_in_sdist_include(self):
+ sdist = load_sdist_config()
+ includes = sdist.get("include", [])
+ assert "scripts/**" in includes, (
+ "pyproject.toml [tool.flit.sdist] must include 'scripts/**'. "
+ "Scripts help voters validate the package (e.g. version_check.py)."
+ )
+
+
+class TestSdistExcludesBinaries:
+ """Verify binary files are excluded to keep tarballs source-only."""
+
+ def test_ipynb_excluded(self):
+ sdist = load_sdist_config()
+ excludes = sdist.get("exclude", [])
+ assert "**/*.ipynb" in excludes, (
+ "pyproject.toml [tool.flit.sdist] must exclude '**/*.ipynb'. "
+ "Notebooks should not be in source tarballs."
+ )
+
+ def test_png_excluded(self):
+ sdist = load_sdist_config()
+ excludes = sdist.get("exclude", [])
+ assert "**/*.png" in excludes, (
+ "pyproject.toml [tool.flit.sdist] must exclude '**/*.png'. "
+ "Binary files should not be in source tarballs."
+ )
diff --git a/dev_tools/language_server/tests/test_sdist.py b/dev_tools/language_server/tests/test_sdist.py
new file mode 100644
index 00000000..0af23da8
--- /dev/null
+++ b/dev_tools/language_server/tests/test_sdist.py
@@ -0,0 +1,62 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Tests verifying that the sdist includes tests.
+
+Per Apache release policy, voters must be able to build from source
+and run tests to validate. These tests ensure that pyproject.toml
+is configured to include tests/ in the source distribution.
+"""
+
+import sys
+from pathlib import Path
+
+if sys.version_info >= (3, 11):
+ import tomllib
+else:
+ import tomli as tomllib
+
+
+def get_lsp_dir() -> Path:
+ return Path(__file__).resolve().parent.parent
+
+
+def load_sdist_config() -> dict:
+ pyproject = get_lsp_dir() / "pyproject.toml"
+ with open(pyproject, "rb") as f:
+ config = tomllib.load(f)
+ return config["tool"]["flit"]["sdist"]
+
+
+class TestSdistIncludesTests:
+ """Verify tests are included in the source distribution."""
+
+ def test_tests_in_sdist_include(self):
+ sdist = load_sdist_config()
+ includes = sdist.get("include", [])
+ assert "tests/**" in includes, (
+ "pyproject.toml [tool.flit.sdist] must include 'tests/**'. "
+ "Apache release policy requires tests in the source tarball."
+ )
+
+ def test_tests_not_in_sdist_exclude(self):
+ sdist = load_sdist_config()
+ excludes = sdist.get("exclude", [])
+ assert "tests/**" not in excludes, (
+ "pyproject.toml [tool.flit.sdist] must not exclude 'tests/**'. "
+ "Apache release policy requires tests in the source tarball."
+ )
diff --git a/ui/backend/tests/test_build.py b/ui/backend/tests/test_build.py
index d891e6a0..b82fc464 100644
--- a/ui/backend/tests/test_build.py
+++ b/ui/backend/tests/test_build.py
@@ -212,6 +212,23 @@ class TestPackageConfiguration:
"Built assets will not be packaged in the distribution."
)
+ def test_flit_sdist_includes_tests(self):
+ """Verify that pyproject.toml includes tests/** in Flit sdist.
+
+ Per Apache release policy, voters must be able to build from source
+ and run tests to validate.
+ """
+ pyproject_file = get_ui_backend_dir() / "pyproject.toml"
+
+ with open(pyproject_file, "rb") as f:
+ config = tomllib.load(f)
+
+ includes = config["tool"]["flit"]["sdist"].get("include", [])
+ assert "tests/**" in includes, (
+ "pyproject.toml [tool.flit.sdist] must include 'tests/**'. "
+ "Apache release policy requires tests in the source tarball."
+ )
+
def test_manifest_in_does_not_exist(self):
"""Verify that MANIFEST.in does not exist (Flit uses pyproject.toml)."""
manifest_file = get_ui_backend_dir() / "MANIFEST.in"
diff --git a/ui/sdk/tests/test_sdist.py b/ui/sdk/tests/test_sdist.py
new file mode 100644
index 00000000..496a8b53
--- /dev/null
+++ b/ui/sdk/tests/test_sdist.py
@@ -0,0 +1,109 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Tests verifying that the sdist includes tests and examples.
+
+Per Apache release policy, voters must be able to build from source
+and run tests to validate. These tests ensure that pyproject.toml
+is configured to include tests/ and examples/ in the source distribution.
+"""
+
+import sys
+from pathlib import Path
+
+if sys.version_info >= (3, 11):
+ import tomllib
+else:
+ import tomli as tomllib
+
+
+def get_sdk_dir() -> Path:
+ return Path(__file__).resolve().parent.parent
+
+
+def load_sdist_config() -> dict:
+ pyproject = get_sdk_dir() / "pyproject.toml"
+ with open(pyproject, "rb") as f:
+ config = tomllib.load(f)
+ return config["tool"]["flit"]["sdist"]
+
+
+class TestSdistIncludesTests:
+ """Verify tests are included in the source distribution."""
+
+ def test_tests_in_sdist_include(self):
+ sdist = load_sdist_config()
+ includes = sdist.get("include", [])
+ assert "tests/**" in includes, (
+ "pyproject.toml [tool.flit.sdist] must include 'tests/**'. "
+ "Apache release policy requires tests in the source tarball."
+ )
+
+ def test_tests_not_in_sdist_exclude(self):
+ sdist = load_sdist_config()
+ excludes = sdist.get("exclude", [])
+ assert "tests/**" not in excludes, (
+ "pyproject.toml [tool.flit.sdist] must not exclude 'tests/**'. "
+ "Apache release policy requires tests in the source tarball."
+ )
+
+
+class TestSdistIncludesExamples:
+ """Verify examples are included in the source distribution."""
+
+ def test_examples_in_sdist_include(self):
+ sdist = load_sdist_config()
+ includes = sdist.get("include", [])
+ assert "examples/**" in includes, (
+ "pyproject.toml [tool.flit.sdist] must include 'examples/**'. "
+ "Examples help voters validate the package works correctly."
+ )
+
+ def test_examples_not_in_sdist_exclude(self):
+ sdist = load_sdist_config()
+ excludes = sdist.get("exclude", [])
+ assert "examples/**" not in excludes, (
+ "pyproject.toml [tool.flit.sdist] must not exclude 'examples/**'."
+ )
+
+
+class TestSdistExcludesBinaries:
+ """Verify binary files are excluded to keep tarballs source-only."""
+
+ def test_parquet_excluded(self):
+ sdist = load_sdist_config()
+ excludes = sdist.get("exclude", [])
+ assert "**/*.parquet" in excludes, (
+ "pyproject.toml [tool.flit.sdist] must exclude '**/*.parquet'. "
+ "Binary files should not be in source tarballs."
+ )
+
+ def test_pkl_excluded(self):
+ sdist = load_sdist_config()
+ excludes = sdist.get("exclude", [])
+ assert "**/*.pkl" in excludes, (
+ "pyproject.toml [tool.flit.sdist] must exclude '**/*.pkl'. "
+ "Binary files should not be in source tarballs."
+ )
+
+ def test_ipynb_excluded(self):
+ sdist = load_sdist_config()
+ excludes = sdist.get("exclude", [])
+ assert "**/*.ipynb" in excludes, (
+ "pyproject.toml [tool.flit.sdist] must exclude '**/*.ipynb'. "
+ "Notebooks should not be in source tarballs."
+ )