From 868917c4e8b733eecf2729d46d813c8ef3ad6f91 Mon Sep 17 00:00:00 2001 From: Sait Cakmak Date: Tue, 29 Oct 2024 06:51:42 -0700 Subject: [PATCH] Fix test_init_files Summary: I randomly came across this test that would've prevented a recent broken release if it has been working. I believe it was written based on the old directory structure (before we moved ax/ax/... to ax/...), and had to be updated to continue working. This diff updates the target directory and adds exclusions for - ax/fb -- these are only used with buck, so no need to enforce __init__ - ax/github -- these are for github templates and workflows, so no need to have them included in builds. They also live in a separate directory in OSS. - tests -- I don't have a strong opinion on this one either way Differential Revision: D65141273 --- ax/health_check/__init__.py | 5 +++++ ax/preview/__init__.py | 5 +++++ ax/preview/api/__init__.py | 5 +++++ ax/telemetry/__init__.py | 5 +++++ ax/utils/testing/test_init_files.py | 9 +++++++-- 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 ax/health_check/__init__.py create mode 100644 ax/preview/__init__.py create mode 100644 ax/preview/api/__init__.py create mode 100644 ax/telemetry/__init__.py diff --git a/ax/health_check/__init__.py b/ax/health_check/__init__.py new file mode 100644 index 00000000000..4b87eb9e4d0 --- /dev/null +++ b/ax/health_check/__init__.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. diff --git a/ax/preview/__init__.py b/ax/preview/__init__.py new file mode 100644 index 00000000000..4b87eb9e4d0 --- /dev/null +++ b/ax/preview/__init__.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. diff --git a/ax/preview/api/__init__.py b/ax/preview/api/__init__.py new file mode 100644 index 00000000000..4b87eb9e4d0 --- /dev/null +++ b/ax/preview/api/__init__.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. diff --git a/ax/telemetry/__init__.py b/ax/telemetry/__init__.py new file mode 100644 index 00000000000..4b87eb9e4d0 --- /dev/null +++ b/ax/telemetry/__init__.py @@ -0,0 +1,5 @@ +#!/usr/bin/env python3 +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under the MIT license found in the +# LICENSE file in the root directory of this source tree. diff --git a/ax/utils/testing/test_init_files.py b/ax/utils/testing/test_init_files.py index d03351a7995..af35a4a1fc3 100644 --- a/ax/utils/testing/test_init_files.py +++ b/ax/utils/testing/test_init_files.py @@ -11,11 +11,16 @@ from ax.utils.common.testutils import TestCase +DIRS_TO_SKIP = ["ax/fb", "ax/github", "tests"] + class InitTest(TestCase): def test_InitFiles(self) -> None: - """__init__.py files are necessary when not using buck targets""" - for root, _dirs, files in os.walk("./ax/ax", topdown=False): + """__init__.py files are necessary for the inclusion of the directories + in pip builds.""" + for root, _, files in os.walk("./ax", topdown=False): + if any(s in root for s in DIRS_TO_SKIP): + continue if len(glob(f"{root}/**/*.py", recursive=True)) > 0: with self.subTest(root): self.assertTrue(