diff --git a/.cursor/rules/testing-patterns.mdc b/.cursor/rules/testing-patterns.mdc index 17e7bb01c..49c6b5d1a 100644 --- a/.cursor/rules/testing-patterns.mdc +++ b/.cursor/rules/testing-patterns.mdc @@ -1,6 +1,6 @@ --- description: Testing patterns and conventions for GiGL components -globs: **/test**.py,**/tests/**,testing/**,**/tests/** +globs: **/test**.py,**/tests/** alwaysApply: false --- # Testing Patterns & Conventions @@ -173,7 +173,7 @@ TEST_EDGES = [ - **Unit tests**: Dir: `tests/unit/` - Fast, isolated tests - **Integration tests**: Dir: `tests/integration/` - Component interaction tests - **End-to-end tests**: Defined in `Makefile` target: `_run_e2e_kfp_test` - Test complete workflows -- **Misc repo wide tests**: Dir: `testing` +- **Config/project-level tests**: Dir: `tests/config_tests` ### Test Execution diff --git a/.dockerignore b/.dockerignore index fdcb6c220..09ca086aa 100644 --- a/.dockerignore +++ b/.dockerignore @@ -65,8 +65,8 @@ do_not_open_source # We ignore this folder as it is used to test our orchestration api. # It simulates how a customer would use GiGL—not as part of a developer workflow. -# See: testing/api_test/README.md for more details. -testing/api_test +# See: tests/api_test/README.md for more details. +tests/api_test # https://github.com/google-github-actions/auth/issues/497 gha-creds-*.json diff --git a/Makefile b/Makefile index cd70a6b96..e15a063f3 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ DOCKER_IMAGE_MAIN_CUDA_NAME_WITH_TAG?=${DOCKER_IMAGE_MAIN_CUDA_NAME}:${DATE} DOCKER_IMAGE_MAIN_CPU_NAME_WITH_TAG?=${DOCKER_IMAGE_MAIN_CPU_NAME}:${DATE} DOCKER_IMAGE_DEV_WORKBENCH_NAME_WITH_TAG?=${DOCKER_IMAGE_DEV_WORKBENCH_NAME}:${DATE} -PYTHON_DIRS:=.github/scripts examples gigl tests snapchat scripts testing +PYTHON_DIRS:=.github/scripts examples gigl tests snapchat scripts PY_TEST_FILES?="*_test.py" # You can override GIGL_TEST_DEFAULT_RESOURCE_CONFIG by setting it in your environment i.e. # adding `export GIGL_TEST_DEFAULT_RESOURCE_CONFIG=your_resource_config` to your shell config (~/.bashrc, ~/.zshrc, etc.) @@ -63,13 +63,13 @@ install_deps: # May include tests that check the sanity of the repo state i.e. ones that may even cause the failure of # installation scripts precondition_tests: - uv run python testing/dep_vars_check.py + uv run python tests/config_tests/dep_vars_check.py run_api_test: - cd testing/api_test && make run_api_test + cd tests/api_test && make run_api_test assert_yaml_configs_parse: - uv run python testing/assert_yaml_configs_parse.py -d . + uv run python tests/config_tests/assert_yaml_configs_parse.py -d . # Set PY_TEST_FILES= to test a specifc file. # Ex. `make unit_test_py PY_TEST_FILES="eval_metrics_test.py"` @@ -123,7 +123,7 @@ integration_test: notebooks_test: - RESOURCE_CONFIG_PATH=${GIGL_TEST_DEFAULT_RESOURCE_CONFIG} python -m testing.notebooks_test + RESOURCE_CONFIG_PATH=${GIGL_TEST_DEFAULT_RESOURCE_CONFIG} python -m tests.config_tests.notebooks_test mock_assets: uv run python -m gigl.src.mocking.dataset_asset_mocking_suite --resource_config_uri="deployment/configs/e2e_cicd_resource_config.yaml" --env test @@ -189,73 +189,73 @@ push_dev_workbench_docker_image: compile_jars run_cora_nalp_e2e_test: compiled_pipeline_path:=${GIGL_E2E_TEST_COMPILED_PIPELINE_PATH} run_cora_nalp_e2e_test: compile_gigl_kubeflow_pipeline run_cora_nalp_e2e_test: - uv run python testing/e2e_tests/e2e_test.py \ + uv run python tests/e2e_tests/e2e_test.py \ --compiled_pipeline_path=$(compiled_pipeline_path) \ - --test_spec_uri="testing/e2e_tests/e2e_tests.yaml" \ + --test_spec_uri="tests/e2e_tests/e2e_tests.yaml" \ --test_names="cora_nalp_test" run_cora_snc_e2e_test: compiled_pipeline_path:=${GIGL_E2E_TEST_COMPILED_PIPELINE_PATH} run_cora_snc_e2e_test: compile_gigl_kubeflow_pipeline run_cora_snc_e2e_test: - uv run python testing/e2e_tests/e2e_test.py \ + uv run python tests/e2e_tests/e2e_test.py \ --compiled_pipeline_path=$(compiled_pipeline_path) \ - --test_spec_uri="testing/e2e_tests/e2e_tests.yaml" \ + --test_spec_uri="tests/e2e_tests/e2e_tests.yaml" \ --test_names="cora_snc_test" run_cora_udl_e2e_test: compiled_pipeline_path:=${GIGL_E2E_TEST_COMPILED_PIPELINE_PATH} run_cora_udl_e2e_test: compile_gigl_kubeflow_pipeline run_cora_udl_e2e_test: - uv run python testing/e2e_tests/e2e_test.py \ + uv run python tests/e2e_tests/e2e_test.py \ --compiled_pipeline_path=$(compiled_pipeline_path) \ - --test_spec_uri="testing/e2e_tests/e2e_tests.yaml" \ + --test_spec_uri="tests/e2e_tests/e2e_tests.yaml" \ --test_names="cora_udl_test" run_dblp_nalp_e2e_test: compiled_pipeline_path:=${GIGL_E2E_TEST_COMPILED_PIPELINE_PATH} run_dblp_nalp_e2e_test: compile_gigl_kubeflow_pipeline run_dblp_nalp_e2e_test: - uv run python testing/e2e_tests/e2e_test.py \ + uv run python tests/e2e_tests/e2e_test.py \ --compiled_pipeline_path=$(compiled_pipeline_path) \ - --test_spec_uri="testing/e2e_tests/e2e_tests.yaml" \ + --test_spec_uri="tests/e2e_tests/e2e_tests.yaml" \ --test_names="dblp_nalp_test" run_hom_cora_sup_e2e_test: compiled_pipeline_path:=${GIGL_E2E_TEST_COMPILED_PIPELINE_PATH} run_hom_cora_sup_e2e_test: compile_gigl_kubeflow_pipeline run_hom_cora_sup_e2e_test: - uv run python testing/e2e_tests/e2e_test.py \ + uv run python tests/e2e_tests/e2e_test.py \ --compiled_pipeline_path=$(compiled_pipeline_path) \ - --test_spec_uri="testing/e2e_tests/e2e_tests.yaml" \ + --test_spec_uri="tests/e2e_tests/e2e_tests.yaml" \ --test_names="hom_cora_sup_test" run_het_dblp_sup_e2e_test: compiled_pipeline_path:=${GIGL_E2E_TEST_COMPILED_PIPELINE_PATH} run_het_dblp_sup_e2e_test: compile_gigl_kubeflow_pipeline run_het_dblp_sup_e2e_test: - uv run python testing/e2e_tests/e2e_test.py \ + uv run python tests/e2e_tests/e2e_test.py \ --compiled_pipeline_path=$(compiled_pipeline_path) \ - --test_spec_uri="testing/e2e_tests/e2e_tests.yaml" \ + --test_spec_uri="tests/e2e_tests/e2e_tests.yaml" \ --test_names="het_dblp_sup_test" run_hom_cora_sup_gs_e2e_test: compiled_pipeline_path:=${GIGL_E2E_TEST_COMPILED_PIPELINE_PATH} run_hom_cora_sup_gs_e2e_test: compile_gigl_kubeflow_pipeline run_hom_cora_sup_gs_e2e_test: - uv run python testing/e2e_tests/e2e_test.py \ + uv run python tests/e2e_tests/e2e_test.py \ --compiled_pipeline_path=$(compiled_pipeline_path) \ - --test_spec_uri="testing/e2e_tests/e2e_tests.yaml" \ + --test_spec_uri="tests/e2e_tests/e2e_tests.yaml" \ --test_names="hom_cora_sup_gs_test" run_het_dblp_sup_gs_e2e_test: compiled_pipeline_path:=${GIGL_E2E_TEST_COMPILED_PIPELINE_PATH} run_het_dblp_sup_gs_e2e_test: compile_gigl_kubeflow_pipeline run_het_dblp_sup_gs_e2e_test: - uv run python testing/e2e_tests/e2e_test.py \ + uv run python tests/e2e_tests/e2e_test.py \ --compiled_pipeline_path=$(compiled_pipeline_path) \ - --test_spec_uri="testing/e2e_tests/e2e_tests.yaml" \ + --test_spec_uri="tests/e2e_tests/e2e_tests.yaml" \ --test_names="het_dblp_sup_gs_test" run_all_e2e_tests: compiled_pipeline_path:=${GIGL_E2E_TEST_COMPILED_PIPELINE_PATH} run_all_e2e_tests: compile_gigl_kubeflow_pipeline run_all_e2e_tests: - uv run python testing/e2e_tests/e2e_test.py \ + uv run python tests/e2e_tests/e2e_test.py \ --compiled_pipeline_path=$(compiled_pipeline_path) \ - --test_spec_uri="testing/e2e_tests/e2e_tests.yaml" + --test_spec_uri="tests/e2e_tests/e2e_tests.yaml" # Compile an instance of a kfp pipeline # If you want to compile a pipeline and save it to a specific path, set compiled_pipeline_path diff --git a/README.md b/README.md index 0dfea8124..0a0789aee 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,7 @@ these tests both locally and on an open PR (leveraring our build/testing system) echo $GIGL_DOCKER_ARTIFACT_REGISTRY ``` - These environment variables override what is defined in the `Makefile`, and when running e2e tests (see: `testing/e2e_tests/e2e_tests.yaml`), allowing you to run tests as discussed below. + These environment variables override what is defined in the `Makefile`, and when running e2e tests (see: `tests/e2e_tests/e2e_tests.yaml`), allowing you to run tests as discussed below. ```` ##### Lint/Formatting & Unit Tests @@ -258,7 +258,7 @@ All integration tests are organized in `tests/integration` folder with the pytho ##### Cloud Integration Test (end-to-end) We have a few e2e test entrypoints defined in the Makefile i.e. `run_cora_nalp_e2e_test`, `run_cora_snc_e2e_test`, etc. -You will note that all these tests are defined in `testing/e2e_tests/e2e_tests.yaml`. +You will note that all these tests are defined in `tests/e2e_tests/e2e_tests.yaml`. ```{caution} As these are very long running tests, we advise you run them on the PR; leveraging commands [pointed out above](#running-tests-against-an-open-pr). diff --git a/testing/README.md b/testing/README.md deleted file mode 100644 index 844c28942..000000000 --- a/testing/README.md +++ /dev/null @@ -1,5 +0,0 @@ -## Test scripts for GiGL as a project. - -This folder is intended for tests at a GiGL *project* level, e.g. lint tests, or "e2e tests". Unit tests and integration -tests should go in their respective directories e.g. Python [unit](../tests/unit/) and -[integration](../tests/integration/) tests. diff --git a/testing/api_test/Makefile b/tests/api_test/Makefile similarity index 100% rename from testing/api_test/Makefile rename to tests/api_test/Makefile diff --git a/testing/api_test/README.md b/tests/api_test/README.md similarity index 100% rename from testing/api_test/README.md rename to tests/api_test/README.md diff --git a/testing/__init__.py b/tests/api_test/__init__.py similarity index 100% rename from testing/__init__.py rename to tests/api_test/__init__.py diff --git a/testing/api_test/api_test_inference.py b/tests/api_test/api_test_inference.py similarity index 100% rename from testing/api_test/api_test_inference.py rename to tests/api_test/api_test_inference.py diff --git a/testing/api_test/api_test_resource_config.yaml b/tests/api_test/api_test_resource_config.yaml similarity index 100% rename from testing/api_test/api_test_resource_config.yaml rename to tests/api_test/api_test_resource_config.yaml diff --git a/testing/api_test/api_test_task_config.yaml b/tests/api_test/api_test_task_config.yaml similarity index 100% rename from testing/api_test/api_test_task_config.yaml rename to tests/api_test/api_test_task_config.yaml diff --git a/testing/api_test/api_test_training.py b/tests/api_test/api_test_training.py similarity index 100% rename from testing/api_test/api_test_training.py rename to tests/api_test/api_test_training.py diff --git a/tests/config_tests/README.md b/tests/config_tests/README.md new file mode 100644 index 000000000..f023c5430 --- /dev/null +++ b/tests/config_tests/README.md @@ -0,0 +1,5 @@ +## Config/project-level test scripts for GiGL. + +This folder is intended for tests at a GiGL *project* level, e.g. lint tests and config validation. Unit tests and +integration tests should go in their respective directories e.g. Python [unit](../unit/) and +[integration](../integration/) tests. E2E tests should go in [e2e_tests](../e2e_tests/). diff --git a/testing/api_test/__init__.py b/tests/config_tests/__init__.py similarity index 100% rename from testing/api_test/__init__.py rename to tests/config_tests/__init__.py diff --git a/testing/assert_yaml_configs_parse.py b/tests/config_tests/assert_yaml_configs_parse.py similarity index 100% rename from testing/assert_yaml_configs_parse.py rename to tests/config_tests/assert_yaml_configs_parse.py diff --git a/testing/dep_vars_check.py b/tests/config_tests/dep_vars_check.py similarity index 79% rename from testing/dep_vars_check.py rename to tests/config_tests/dep_vars_check.py index aa4333fc6..e7b329955 100644 --- a/testing/dep_vars_check.py +++ b/tests/config_tests/dep_vars_check.py @@ -1,7 +1,9 @@ from pathlib import Path -# We're in GiGL/testing, so we need to go up one level to find gigl/dep_vars.env -DEP_VARS_FILE_PATH = Path.joinpath(Path(__file__).parent.parent, "gigl", "dep_vars.env") +# We're in GiGL/tests/config_tests, so we need to go up two levels to find GiGL/gigl/dep_vars.env +DEP_VARS_FILE_PATH = Path.joinpath( + Path(__file__).parent.parent.parent, "gigl", "dep_vars.env" +) if __name__ == "__main__": assert ( diff --git a/testing/notebooks_test.py b/tests/config_tests/notebooks_test.py similarity index 100% rename from testing/notebooks_test.py rename to tests/config_tests/notebooks_test.py diff --git a/testing/e2e_tests/__init__.py b/tests/e2e_tests/__init__.py similarity index 100% rename from testing/e2e_tests/__init__.py rename to tests/e2e_tests/__init__.py diff --git a/testing/e2e_tests/e2e_test.py b/tests/e2e_tests/e2e_test.py similarity index 100% rename from testing/e2e_tests/e2e_test.py rename to tests/e2e_tests/e2e_test.py diff --git a/testing/e2e_tests/e2e_tests.yaml b/tests/e2e_tests/e2e_tests.yaml similarity index 100% rename from testing/e2e_tests/e2e_tests.yaml rename to tests/e2e_tests/e2e_tests.yaml