Skip to content

Commit

Permalink
Fix test_init_files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
saitcakmak authored and facebook-github-bot committed Oct 29, 2024
1 parent 7d8635c commit 868917c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ax/health_check/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions ax/preview/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions ax/preview/api/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
5 changes: 5 additions & 0 deletions ax/telemetry/__init__.py
Original file line number Diff line number Diff line change
@@ -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.
9 changes: 7 additions & 2 deletions ax/utils/testing/test_init_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 868917c

Please sign in to comment.