Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hook for Hydra config system (hydra-core) #470

Merged
merged 1 commit into from
Jul 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/424.new.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add hook for Hydra config system (``hydra-core``).
1 change: 1 addition & 0 deletions requirements-test-libraries.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ great-expectations==0.15.13
tensorflow==2.9.1
pyshark==0.4.6
opencv-python==4.6.0.66
hydra-core==1.2.0

# ------------------- Platform (OS) specifics

Expand Down
19 changes: 19 additions & 0 deletions src/_pyinstaller_hooks_contrib/hooks/stdhooks/hook-hydra.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# ------------------------------------------------------------------
# Copyright (c) 2022 PyInstaller Development Team.
#
# This file is distributed under the terms of the GNU General Public
# License (version 2.0 or later).
#
# The full license is available in LICENSE.GPL.txt, distributed with
# this software.
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------

from PyInstaller.utils.hooks import collect_submodules, collect_data_files

# Collect core plugins.
hiddenimports = collect_submodules('hydra._internal.core_plugins')

# Collect package's data files, such as default configuration files.
datas = collect_data_files('hydra')
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_group:
secret_string: secret
secret_number: 123
31 changes: 30 additions & 1 deletion src/_pyinstaller_hooks_contrib/tests/test_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
# ------------------------------------------------------------------
import pytest

import os
from pathlib import Path

import pytest

from PyInstaller.compat import is_darwin, is_linux, is_py39, is_win
from PyInstaller.utils.hooks import is_module_satisfies, can_import_module
from PyInstaller.utils.tests import importorskip, requires, xfail
Expand Down Expand Up @@ -1276,3 +1280,28 @@ def test_pyqtgraph(pyi_builder):
import pyqtgraph.imageview.ImageView
"""
)


@importorskip('hydra')
def test_hydra(pyi_builder, tmpdir):
config_file = str((Path(__file__) / '../data/test_hydra/config.yaml').resolve(strict=True).as_posix())

pyi_builder.test_source(
"""
import os

import hydra
from omegaconf import DictConfig, OmegaConf

config_path = os.path.join(os.path.dirname(__file__), 'conf')

@hydra.main(config_path=config_path, config_name="config")
def my_app(cfg):
assert cfg.test_group.secret_string == 'secret'
assert cfg.test_group.secret_number == 123

if __name__ == "__main__":
my_app()
""",
pyi_args=['--add-data', os.pathsep.join((config_file, 'conf'))]
)