diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index a9933161a0c..00000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,326 +0,0 @@ -version: 2.1 - -parameters: - plugin_test: - type: boolean - default: False - test_plugins: - type: string - default: "" - cache_key_version: - type: string - default: v1 - -commands: - early_return_for_forked_pull_requests: - description: >- - If this build is from a fork, stop executing the current job and return success. - This is useful to avoid steps that will fail due to missing credentials. - steps: - - run: - name: Early return if this build is from a forked PR - command: | - if [ -n "$CIRCLE_PR_NUMBER" ]; then - echo "Nothing to do for forked PRs, so marking this step successful" - circleci step halt - fi - macos: - description: Commands run on MacOS - parameters: - py_version: - type: string - steps: - - checkout - - restore_cache: - key: -<< pipeline.parameters.cache_key_version >>-macos-sys-{{ .Branch }}-<< parameters.py_version >> - - run: - name: Preparing environment - Conda - command: | - if [[ -f ~/miniconda3/LICENSE.txt ]] ; then - echo "miniconda installed already." - else - curl -o Miniconda3-py39_24.5.0-0-MacOSX-arm64.sh https://repo.anaconda.com/miniconda/Miniconda3-py39_24.5.0-0-MacOSX-arm64.sh - bash ./Miniconda3-py39_24.5.0-0-MacOSX-arm64.sh -b - fi - ~/miniconda3/bin/conda init bash - - run: - name: Preparing environment - Brew - command: | - brew update - brew upgrade git - brew install fish - brew install zsh - brew cleanup - - run: - name: Preparing environment - Hydra - command: | - conda create -n hydra python=<< parameters.py_version >> -yqc conda-forge - conda run -n hydra pip install nox --progress-bar off - - save_cache: - key: -<< pipeline.parameters.cache_key_version >>-macos-sys-{{ .Branch }}-<< parameters.py_version >> - paths: - - ~/miniconda3 - - ~/Library/Caches/Homebrew - - - linux: - description: Commands run on Linux - parameters: - py_version: - type: string - steps: - - checkout - - run: - name: Preparing environment - Conda - command: | - curl -o Miniconda3-py38_4.8.3-Linux-x86_64.sh https://repo.anaconda.com/miniconda/Miniconda3-py38_4.8.3-Linux-x86_64.sh - bash ./Miniconda3-py38_4.8.3-Linux-x86_64.sh -b - - run: - name: Preparing environment - Other dependency - command: | - sudo apt-get update - sudo apt-get install -y expect fish zsh openjdk-11-jre rsync - - run: - name: Preparing environment - Hydra - command: | - ~/miniconda3/bin/conda init bash - ~/miniconda3/bin/conda create -n hydra python=<< parameters.py_version >> -yqc conda-forge - - - win: - description: Commands run on Windows - parameters: - py_version: - type: string - steps: - - checkout - - restore_cache: - key: -<< pipeline.parameters.cache_key_version >>-win-sys-{{ .Branch }}-<< parameters.py_version >> - - run: - name: Preparing environment - system - command: | - choco install -y --no-progress miniconda3 - choco install -y --no-progress openssl openjdk11jre - C:\tools\miniconda3\Scripts\conda.exe init powershell - - run: - name: Preparing environment - Hydra - command: | - conda create -n hydra python=<< parameters.py_version >> -yqc conda-forge - conda activate hydra - pip install nox dataclasses --progress-bar off - - save_cache: - key: -<< pipeline.parameters.cache_key_version >>-win-sys-{{ .Branch }}-<< parameters.py_version >> - paths: - - C:\tools\miniconda3 - -jobs: - test_macos: - parameters: - py_version: - type: string - macos: - xcode: "13.4.1" - steps: - - macos: - py_version: << parameters.py_version >> - - run: - name: Testing Hydra - no_output_timeout: 10m - command: | - export NOX_PYTHON_VERSIONS=<< parameters.py_version >> - conda activate hydra - pip install nox dataclasses --progress-bar off - if [ -n "$CIRCLE_PR_NUMBER" ]; then - nox -s lint test_tools test_core \ - test_jupyter_notebooks lint_plugins test_plugins test_plugins_vs_core -ts - else - nox -s lint test_tools test_core test_jupyter_notebooks -ts - fi - test_linux: - parameters: - py_version: - type: string - docker: - - image: cimg/base:stable-18.04 - steps: - - linux: - py_version: << parameters.py_version >> - - run: - name: Testing Hydra - command: | - export PATH="$HOME/miniconda3/envs/hydra/bin:$PATH" - export NOX_PYTHON_VERSIONS=<< parameters.py_version >> - pip install nox dataclasses --progress-bar off - if [ -n "$CIRCLE_PR_NUMBER" ]; then - nox -s lint test_tools test_core \ - test_jupyter_notebooks lint_plugins test_plugins test_plugins_vs_core -ts - else - nox -s lint test_tools test_core test_jupyter_notebooks -ts - fi - test_win: - parameters: - py_version: - type: string - executor: win/default - steps: - - win: - py_version: << parameters.py_version >> - - run: - name: Testing Hydra - no_output_timeout: 10m - command: | - $env:NOX_PYTHON_VERSIONS="<< parameters.py_version >>" - $env:ConEmuDefaultCp=65001 - $env:PYTHONIOENCODING="utf_8" - conda activate hydra - If ($env:CIRCLE_PR_NUMBER) { - nox -s lint test_tools test_core test_jupyter_notebooks lint_plugins test_plugins test_plugins_vs_core -ts - } else { - nox -s lint test_tools test_core test_jupyter_notebooks -ts - } - exit $LASTEXITCODE - trigger_plugin_pipelines: - docker: - - image: circleci/python:3.8 - steps: - - early_return_for_forked_pull_requests - - checkout - - run: - name: Kick off Plugin tests - command: | - python tools/ci/circleci_pipeline.py - echo "Done kicking off plugin tests." - test_plugin_macos: - parameters: - py_version: - type: string - test_plugin: - type: string - macos: - xcode: "13.4.1" - steps: - - macos: - py_version: << parameters.py_version >> - - run: - name: << parameters.test_plugin >> - no_output_timeout: 10m - command: | - export NOX_PYTHON_VERSIONS=<< parameters.py_version >> - export PLUGINS=<< parameters.test_plugin >> - conda activate hydra - pip install nox dataclasses --progress-bar off - nox -s lint_plugins test_plugins test_plugins_vs_core -ts - test_plugin_linux: - parameters: - py_version: - type: string - test_plugin: - type: string - docker: - - image: cimg/base:stable-18.04 - # https://github.com/facebookresearch/hydra/pull/1691 - resource_class: medium+ - steps: - - linux: - py_version: << parameters.py_version >> - - run: - name: << parameters.test_plugin >> - command: | - export PATH="$HOME/miniconda3/envs/hydra/bin:$PATH" - export NOX_PYTHON_VERSIONS=<< parameters.py_version >> - export PLUGINS=<< parameters.test_plugin >> - pip install nox dataclasses --progress-bar off - nox -s lint_plugins test_plugins test_plugins_vs_core -ts - test_plugin_win: - parameters: - py_version: - type: string - test_plugin: - type: string - executor: win/default - steps: - - win: - py_version: << parameters.py_version >> - - run: - name: << parameters.test_plugin >> - no_output_timeout: 10m - command: | - $env:NOX_PYTHON_VERSIONS="<< parameters.py_version >>" - $env:ConEmuDefaultCp=65001 - $env:PYTHONIOENCODING="utf_8" - $env:PLUGINS="<< parameters.test_plugin >>" - conda activate hydra - nox -s lint_plugins test_plugins test_plugins_vs_core -ts - exit $LASTEXITCODE - test_linux_omc_dev: - parameters: - py_version: - type: string - docker: - - image: cimg/base:stable-18.04 - steps: - - linux: - py_version: << parameters.py_version >> - - run: - name: Testing Hydra - command: | - export PATH="$HOME/miniconda3/envs/hydra/bin:$PATH" - export NOX_PYTHON_VERSIONS=<< parameters.py_version >> - export USE_OMEGACONF_DEV_VERSION=1 - pip install nox dataclasses --progress-bar off - nox -s test_core -ts - # Misc - coverage: - docker: - - image: circleci/python:3.8 - steps: - - checkout - - run: sudo pip install nox --progress-bar off - - run: nox -s coverage - -workflows: - version: 2 - core_tests: - unless: << pipeline.parameters.plugin_test >> - jobs: - - trigger_plugin_pipelines - - test_macos: - matrix: - parameters: - py_version: ["3.8", "3.9", "3.10", "3.11"] - - test_linux: - matrix: - parameters: - py_version: ["3.8", "3.9", "3.10", "3.11"] - - test_win: - matrix: - parameters: - py_version: ["3.8", "3.9", "3.10", "3.11"] - - test_linux_omc_dev: - matrix: - parameters: - py_version: ["3.8", "3.9", "3.10", "3.11"] - - - plugin_tests: - when: << pipeline.parameters.plugin_test >> - jobs: - - test_plugin_linux: - matrix: - parameters: - py_version: ["3.8", "3.9", "3.10", "3.11"] - test_plugin: [<< pipeline.parameters.test_plugins >>] - - test_plugin_macos: - matrix: - parameters: - py_version: ["3.8", "3.9", "3.10", "3.11"] - test_plugin: [<< pipeline.parameters.test_plugins >>] - - test_plugin_win: - matrix: - parameters: - py_version: ["3.8", "3.9", "3.10", "3.11"] - test_plugin: [<< pipeline.parameters.test_plugins >>] - - -orbs: - win: circleci/windows@2.2.0 diff --git a/.github/actions/linux/action.yml b/.github/actions/linux/action.yml new file mode 100644 index 00000000000..e22b3a35d8d --- /dev/null +++ b/.github/actions/linux/action.yml @@ -0,0 +1,22 @@ +name: linux +inputs: + py_version: + required: false +runs: + using: composite + steps: + - name: Preparing environment - Conda + run: |- + curl -o Miniconda3-py38_4.8.3-Linux-x86_64.sh https://repo.anaconda.com/miniconda/Miniconda3-py38_4.8.3-Linux-x86_64.sh + bash ./Miniconda3-py38_4.8.3-Linux-x86_64.sh -b + shell: bash + - name: Preparing environment - Other dependency + run: |- + sudo apt-get update + sudo apt-get install -y expect fish zsh openjdk-11-jre rsync + shell: bash + - name: Preparing environment - Hydra + run: |- + ~/miniconda3/bin/conda init bash + ~/miniconda3/bin/conda create -n hydra python=${{ inputs.py_version }} -yqc conda-forge + shell: bash diff --git a/.github/actions/macos/action.yml b/.github/actions/macos/action.yml new file mode 100644 index 00000000000..44690c4c630 --- /dev/null +++ b/.github/actions/macos/action.yml @@ -0,0 +1,49 @@ +name: macos +inputs: + py_version: + required: false +runs: + using: composite + steps: + - name: restore_cache + uses: actions/cache@v3.3.2 + with: + key: "-${{ inputs.cache_key_version }}-macos-sys-{{ .Branch }}-${{ inputs.py_version }}" + path: |- + ~/miniconda3 + ~/Library/Caches/Homebrew + - uses: maxim-lobanov/setup-xcode@v1.6.0 + with: + xcode-version: latest-stable + - name: Preparing environment - Conda + run: |- + if [[ -f ~/miniconda3/LICENSE.txt ]] ; then + echo "miniconda installed already." + else + curl -o Miniconda3-py39_24.5.0-0-MacOSX-arm64.sh https://repo.anaconda.com/miniconda/Miniconda3-py39_24.5.0-0-MacOSX-arm64.sh + bash ./Miniconda3-py39_24.5.0-0-MacOSX-arm64.sh -b + fi + ~/miniconda3/bin/conda init bash + shell: bash + - name: Preparing environment - Brew + run: |- + brew update + brew upgrade git + brew install fish + brew install zsh + brew cleanup + shell: bash + - name: Preparing environment - Hydra + run: |- + source $HOME/.bash_profile + echo $PATH + conda create -n hydra python=${{ inputs.py_version }} -yqc conda-forge + conda run -n hydra pip install nox --progress-bar off + shell: bash + - name: save_cache + uses: actions/cache@v3.3.2 + with: + path: |- + ~/miniconda3 + ~/Library/Caches/Homebrew + key: "-${{ inputs.cache_key_version }}-macos-sys-{{ .Branch }}-${{ inputs.py_version }}" diff --git a/.github/actions/windows/action.yml b/.github/actions/windows/action.yml new file mode 100644 index 00000000000..091d8c664d3 --- /dev/null +++ b/.github/actions/windows/action.yml @@ -0,0 +1,16 @@ +name: windows +inputs: + py_version: + required: true +runs: + using: composite + steps: + - uses: conda-incubator/setup-miniconda@v3 + with: + miniconda-version: "latest" + python-version: ${{ inputs.py_version }} + activate-environment: hydra + - uses: actions/setup-java@v4 + with: + distribution: 'microsoft' + java-version: '21' diff --git a/.github/workflows/core_tests.yml b/.github/workflows/core_tests.yml new file mode 100644 index 00000000000..b97f5a88be3 --- /dev/null +++ b/.github/workflows/core_tests.yml @@ -0,0 +1,88 @@ +name: facebookresearch/hydra/core_tests +on: + push +jobs: + test_macos: + runs-on: macos-latest + strategy: + matrix: + py_version: + - '3.8' + - '3.9' + - '3.10' + - '3.11' + steps: + - uses: actions/checkout@v4.1.0 + - uses: "./.github/actions/macos" + with: + py_version: "${{ matrix.py_version }}" + - name: Testing Hydra + run: |- + source $HOME/.bash_profile + export NOX_PYTHON_VERSIONS=${{ matrix.py_version }} + conda activate hydra + pip install nox dataclasses --progress-bar off + nox -s lint test_tools test_core \ + test_jupyter_notebooks lint_plugins test_plugins test_plugins_vs_core -ts + test_linux: + runs-on: ubuntu-latest + strategy: + matrix: + py_version: + - '3.8' + - '3.9' + - '3.10' + - '3.11' + steps: + - uses: actions/checkout@v4.1.0 + - uses: "./.github/actions/linux" + with: + py_version: "${{ matrix.py_version }}" + - name: Testing Hydra + run: |- + export PATH="$HOME/miniconda3/envs/hydra/bin:$PATH" + export NOX_PYTHON_VERSIONS=${{ matrix.py_version }} + pip install nox dataclasses --progress-bar off + nox -s lint test_tools test_core \ + test_jupyter_notebooks lint_plugins test_plugins test_plugins_vs_core -ts + test_win: + runs-on: windows-latest + strategy: + matrix: + py_version: + - '3.8' + - '3.9' + - '3.10' + - '3.11' + steps: + - uses: actions/checkout@v4.1.0 + - uses: "./.github/actions/windows" + - name: Testing Hydra + run: |- + conda run -n hydra pip install nox --progress-bar off + set NOX_PYTHON_VERSIONS="${{ matrix.py_version }}" + set ConEmuDefaultCp=65001 + set PYTHONIOENCODING="utf_8" + nox -s lint test_tools test_core test_jupyter_notebooks lint_plugins test_plugins test_plugins_vs_core -ts + exit $LASTEXITCODE + test_linux_omc_dev: + runs-on: ubuntu-latest + strategy: + matrix: + py_version: + - '3.8' + - '3.9' + - '3.10' + - '3.11' + steps: + - uses: actions/checkout@v4.1.0 + - uses: "./.github/actions/linux" + with: + py_version: "${{ matrix.py_version }}" + - name: Testing Hydra + run: |- + export PATH="$HOME/miniconda3/envs/hydra/bin:$PATH" + export NOX_PYTHON_VERSIONS=${{ matrix.py_version }} + export USE_OMEGACONF_DEV_VERSION=1 + pip install nox dataclasses --progress-bar off + nox -s test_core -ts diff --git a/examples/advanced/hydra_app_example/tests/test_installed_app.py b/examples/advanced/hydra_app_example/tests/test_installed_app.py index 633410099af..b4fbd005f2e 100644 --- a/examples/advanced/hydra_app_example/tests/test_installed_app.py +++ b/examples/advanced/hydra_app_example/tests/test_installed_app.py @@ -16,7 +16,7 @@ def test_python_run(self, tmpdir: str) -> None: [ sys.executable, "hydra_app/main.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "app.user=test_user", ] ) @@ -26,7 +26,7 @@ def test_python_run(self, tmpdir: str) -> None: def test_installed_run(self, tmpdir: str) -> None: self.verify_output( subprocess.check_output( - ["hydra_app", f"hydra.run.dir={tmpdir}", "app.user=test_user"] + ["hydra_app", f'hydra.run.dir="{tmpdir}"', "app.user=test_user"] ) ) diff --git a/hydra/test_utils/launcher_common_tests.py b/hydra/test_utils/launcher_common_tests.py index af2346a489d..aedafe7a08e 100644 --- a/hydra/test_utils/launcher_common_tests.py +++ b/hydra/test_utils/launcher_common_tests.py @@ -657,6 +657,9 @@ def test_to_absolute_path_multirun( cfg = OmegaConf.merge(task_launcher_cfg, task_config) assert isinstance(cfg, DictConfig) path = str(Path("/foo/bar").absolute()) + # Hack to use the right drive on windows + if path.startswith("D:"): + path = path.replace("D:", "C:", 1) integration_test( tmpdir=self.get_test_scratch_dir(tmpdir), task_config=cfg, diff --git a/hydra/test_utils/test_utils.py b/hydra/test_utils/test_utils.py index 8874bd81873..768701de373 100644 --- a/hydra/test_utils/test_utils.py +++ b/hydra/test_utils/test_utils.py @@ -69,7 +69,7 @@ def __enter__(self) -> "TaskTestFunction": self.temp_dir = tempfile.mkdtemp() overrides = copy.deepcopy(self.overrides) assert overrides is not None - overrides.append(f"hydra.run.dir={self.temp_dir}") + overrides.append(f'hydra.run.dir="{self.temp_dir}"') self.job_ret = self.hydra.run( config_name=self.config_name, task_function=self, diff --git a/plugins/hydra_ax_sweeper/tests/test_ax_sweeper_plugin.py b/plugins/hydra_ax_sweeper/tests/test_ax_sweeper_plugin.py index e8dda25e281..0b6c40e9290 100644 --- a/plugins/hydra_ax_sweeper/tests/test_ax_sweeper_plugin.py +++ b/plugins/hydra_ax_sweeper/tests/test_ax_sweeper_plugin.py @@ -216,7 +216,7 @@ def test_ax_logging(tmpdir: Path, cmd_arg: str, expected_str: str) -> None: cmd = [ "tests/apps/polynomial.py", "-m", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "polynomial.x=interval(-5, -2)", "polynomial.z=10", @@ -239,7 +239,7 @@ def test_search_space_exhausted_exception(tmpdir: Path, cmd_args: List[str]) -> cmd = [ "tests/apps/polynomial.py", "-m", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "hydra.sweeper.ax_config.max_trials=2", ] + cmd_args @@ -260,7 +260,7 @@ def test_search_space_with_constraint_metric(tmpdir: Path, cmd_args: List[str]) cmd = [ "tests/apps/polynomial_with_constraint.py", "-m", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "hydra.sweeper.ax_config.max_trials=2", ] + cmd_args @@ -294,7 +294,7 @@ def test_jobs_using_choice_between_lists( cmd = [ "tests/apps/polynomial_with_list_coefficients.py", "-m", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "hydra.sweeper.ax_config.max_trials=3", ] + [cmd_arg] @@ -331,7 +331,7 @@ def test_jobs_using_choice_between_dicts( cmd = [ "tests/apps/polynomial_with_dict_coefficients.py", "-m", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "hydra.sweeper.ax_config.max_trials=3", ] + [cmd_arg] @@ -345,7 +345,7 @@ def test_example_app(tmpdir: Path) -> None: cmd = [ "example/banana.py", "-m", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "banana.x=int(interval(-5, 5))", "banana.y=interval(-5, 10.1)", diff --git a/tests/jupyter/%run_test.ipynb b/tests/jupyter/%run_test.ipynb index f32b6245cef..beb7a987ea5 100644 --- a/tests/jupyter/%run_test.ipynb +++ b/tests/jupyter/%run_test.ipynb @@ -50,7 +50,7 @@ "source": [ "import tempfile\n", "tmpdir = tempfile.mkdtemp()\n", - "%run ../../examples/tutorials/basic/your_first_hydra_app/6_composition/my_app.py hydra.run.dir=$tmpdir hydra.job.chdir=True" + "%run ../../examples/tutorials/basic/your_first_hydra_app/6_composition/my_app.py hydra.run.dir='\"$tmpdir\"' hydra.job.chdir=True" ] } ], @@ -75,4 +75,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} \ No newline at end of file +} diff --git a/tests/test_apps/app_with_unicode_in_config/my_app.py b/tests/test_apps/app_with_unicode_in_config/my_app.py index 0839a3c526d..d89625ecbbf 100644 --- a/tests/test_apps/app_with_unicode_in_config/my_app.py +++ b/tests/test_apps/app_with_unicode_in_config/my_app.py @@ -1,4 +1,6 @@ # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved +import sys + from omegaconf import DictConfig, OmegaConf import hydra @@ -6,6 +8,7 @@ @hydra.main(version_base=None, config_path=".", config_name="config") def my_app(cfg: DictConfig) -> None: + sys.stdout.reconfigure(encoding="utf-8") # type: ignore print(OmegaConf.to_yaml(cfg)) diff --git a/tests/test_basic_sweeper.py b/tests/test_basic_sweeper.py index d7464ec10bc..0d2b0dc89a0 100644 --- a/tests/test_basic_sweeper.py +++ b/tests/test_basic_sweeper.py @@ -70,7 +70,7 @@ def test_partial_failure( "tests/test_apps/app_can_fail/my_app.py", "--multirun", "+divisor=1,0", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "hydra.hydra_logging.formatters.simple.format='[HYDRA] %(message)s'", ] diff --git a/tests/test_callbacks.py b/tests/test_callbacks.py index 992b70c1e27..adc1f428335 100644 --- a/tests/test_callbacks.py +++ b/tests/test_callbacks.py @@ -98,7 +98,7 @@ def test_app_with_callbacks( ) -> None: cmd = [ app_path, - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "hydra.hydra_logging.formatters.simple.format='[HYDRA] %(message)s'", "hydra.job_logging.formatters.simple.format='[JOB] %(message)s'", @@ -120,7 +120,7 @@ def test_experimental_save_job_info_callback(tmpdir: Path, multirun: bool) -> No cmd = [ app_path, - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.sweep.dir=" + str(tmpdir), "hydra.job.chdir=True", ] @@ -167,7 +167,7 @@ def test_save_job_return_callback(tmpdir: Path, multirun: bool) -> None: cmd = [ sys.executable, app_path, - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.sweep.dir=" + str(tmpdir), "hydra.job.chdir=True", ] @@ -202,7 +202,7 @@ def test_experimental_rerun( cmd = [ app_path, - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.sweep.dir=" + str(tmpdir), "hydra.job.chdir=False", "hydra.hydra_logging.formatters.simple.format='[HYDRA] %(message)s'", diff --git a/tests/test_env_defaults.py b/tests/test_env_defaults.py index 796bffc0b70..94bdeeb90da 100644 --- a/tests/test_env_defaults.py +++ b/tests/test_env_defaults.py @@ -9,7 +9,7 @@ def test_env_defaults(tmpdir: Path) -> None: cmd = [ "tests/test_apps/custom_env_defaults/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] run_python_script(cmd) diff --git a/tests/test_examples/test_advanced_config_search_path.py b/tests/test_examples/test_advanced_config_search_path.py index 64d4508f329..2eccd734f40 100644 --- a/tests/test_examples/test_advanced_config_search_path.py +++ b/tests/test_examples/test_advanced_config_search_path.py @@ -36,7 +36,7 @@ def test_config_search_path( ) -> None: cmd = [ "examples/advanced/config_search_path/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] cmd.extend(args) diff --git a/tests/test_examples/test_advanced_package_overrides.py b/tests/test_examples/test_advanced_package_overrides.py index 5c393704eb1..4004d551d4c 100644 --- a/tests/test_examples/test_advanced_package_overrides.py +++ b/tests/test_examples/test_advanced_package_overrides.py @@ -11,7 +11,7 @@ def test_advanced_package_override_simple(tmpdir: Path) -> None: cmd = [ "examples/advanced/package_overrides/simple.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -23,7 +23,7 @@ def test_advanced_package_override_simple(tmpdir: Path) -> None: def test_advanced_package_override_two_packages(tmpdir: Path) -> None: cmd = [ "examples/advanced/package_overrides/two_packages.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) diff --git a/tests/test_examples/test_basic_sweep.py b/tests/test_examples/test_basic_sweep.py index 899412d477a..8e1ac120ea5 100644 --- a/tests/test_examples/test_basic_sweep.py +++ b/tests/test_examples/test_basic_sweep.py @@ -70,7 +70,7 @@ def test_basic_sweep_example( cmd = [ app_path, "--multirun", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "hydra.hydra_logging.formatters.simple.format='[HYDRA] %(message)s'", "hydra.job_logging.formatters.simple.format='[JOB] %(message)s'", diff --git a/tests/test_examples/test_configure_hydra.py b/tests/test_examples/test_configure_hydra.py index 27a3e35fe4b..e7795ae79df 100644 --- a/tests/test_examples/test_configure_hydra.py +++ b/tests/test_examples/test_configure_hydra.py @@ -16,7 +16,7 @@ def test_custom_help(tmpdir: Path) -> None: result, _err = run_python_script( [ "examples/configure_hydra/custom_help/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "--help", ] @@ -55,7 +55,7 @@ def test_custom_help(tmpdir: Path) -> None: def test_job_name_no_config_override(tmpdir: Path) -> None: cmd = [ "examples/configure_hydra/job_name/no_config_file_override.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -65,7 +65,7 @@ def test_job_name_no_config_override(tmpdir: Path) -> None: def test_job_name_with_config_override(tmpdir: Path) -> None: cmd = [ "examples/configure_hydra/job_name/with_config_file_override.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -90,7 +90,7 @@ def test_job_override_dirname(tmpdir: Path) -> None: def test_logging(tmpdir: Path) -> None: cmd = [ "examples/configure_hydra/logging/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -100,7 +100,7 @@ def test_logging(tmpdir: Path) -> None: def test_disabling_logging(tmpdir: Path) -> None: cmd = [ "examples/configure_hydra/logging/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "hydra/job_logging=none", "hydra/hydra_logging=none", diff --git a/tests/test_examples/test_experimental.py b/tests/test_examples/test_experimental.py index f3f903d4556..1ad7e3f6ad9 100644 --- a/tests/test_examples/test_experimental.py +++ b/tests/test_examples/test_experimental.py @@ -8,7 +8,7 @@ def test_rerun(tmpdir: Path) -> None: cmd = [ "examples/experimental/rerun/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "hydra.hydra_logging.formatters.simple.format='[HYDRA] %(message)s'", "hydra.job_logging.formatters.simple.format='[JOB] %(message)s'", diff --git a/tests/test_examples/test_instantiate_examples.py b/tests/test_examples/test_instantiate_examples.py index 324bb0b425c..785c86abed4 100644 --- a/tests/test_examples/test_instantiate_examples.py +++ b/tests/test_examples/test_instantiate_examples.py @@ -24,7 +24,7 @@ def test_instantiate_object(tmpdir: Path, overrides: List[str], output: str) -> None: cmd = [ "examples/instantiate/object/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] + overrides result, _err = run_python_script(cmd) @@ -46,7 +46,7 @@ def test_instantiate_object_recursive( ) -> None: cmd = [ "examples/instantiate/object_recursive/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] + overrides result, _err = run_python_script(cmd) @@ -56,7 +56,7 @@ def test_instantiate_object_recursive( def test_instantiate_object_partial(tmpdir: Path) -> None: cmd = [ "examples/instantiate/partial/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -73,7 +73,7 @@ def test_instantiate_object_partial(tmpdir: Path) -> None: def test_instantiate_schema(tmpdir: Path, overrides: List[str], output: str) -> None: cmd = [ "examples/instantiate/schema/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] + overrides result, _err = run_python_script(cmd) @@ -102,7 +102,7 @@ def test_instantiate_schema_recursive( ) -> None: cmd = [ "examples/instantiate/schema_recursive/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] + overrides result, _err = run_python_script(cmd) @@ -141,7 +141,7 @@ def test_instantiate_docs_example( ) -> None: cmd = [ "examples/instantiate/docs_example/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] + overrides result, _err = run_python_script(cmd) diff --git a/tests/test_examples/test_patterns.py b/tests/test_examples/test_patterns.py index 5bb60f23af1..c569eef4eb7 100644 --- a/tests/test_examples/test_patterns.py +++ b/tests/test_examples/test_patterns.py @@ -39,7 +39,7 @@ def test_specializing_config_example( def test_write_protect_config_node(tmpdir: Any) -> None: cmd = [ "examples/patterns/write_protect_config_node/frozen.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "data_bits=10", ] @@ -71,7 +71,7 @@ def test_extending_configs( monkeypatch.chdir("examples/patterns/extending_configs") cmd = [ "my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] + overrides result, _err = run_python_script(cmd) @@ -112,7 +112,7 @@ def test_configuring_experiments( monkeypatch.chdir("examples/patterns/configuring_experiments") cmd = [ "my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] + overrides result, _err = run_python_script(cmd) @@ -183,7 +183,7 @@ def test_multi_select( monkeypatch.chdir("examples/patterns/multi-select") cmd = [ "my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] + overrides result, _err = run_python_script(cmd) diff --git a/tests/test_examples/test_structured_configs_tutorial.py b/tests/test_examples/test_structured_configs_tutorial.py index 19022d2d76b..4c859f6269b 100644 --- a/tests/test_examples/test_structured_configs_tutorial.py +++ b/tests/test_examples/test_structured_configs_tutorial.py @@ -20,7 +20,7 @@ def test_1_basic_run(tmpdir: Path) -> None: result, _err = run_python_script( [ "examples/tutorials/structured_configs/1_minimal/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] ) @@ -37,7 +37,7 @@ def test_1_basic_run_with_override_error(tmpdir: Path) -> None: err = run_with_error( [ "examples/tutorials/structured_configs/1_minimal/my_app_type_error.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] ) @@ -48,7 +48,7 @@ def test_1_basic_override(tmpdir: Path) -> None: result, _err = run_python_script( [ "examples/tutorials/structured_configs/1_minimal/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "port=9090", ] @@ -59,7 +59,7 @@ def test_1_basic_override(tmpdir: Path) -> None: def test_1_basic_override_type_error(tmpdir: Path) -> None: cmd = [ "examples/tutorials/structured_configs/1_minimal/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "port=foo", ] @@ -79,7 +79,7 @@ def test_2_static_complex(tmpdir: Path) -> None: result, _err = run_python_script( [ "examples/tutorials/structured_configs/2_static_complex/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] ) @@ -99,7 +99,7 @@ def test_2_static_complex(tmpdir: Path) -> None: def test_3_config_groups(tmpdir: Path, overrides: Any, expected: Any) -> None: cmd = [ "examples/tutorials/structured_configs/3_config_groups/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] cmd.extend(overrides) @@ -134,7 +134,7 @@ def test_3_config_groups_with_inheritance( ) -> None: cmd = [ "examples/tutorials/structured_configs/3_config_groups/my_app_with_inheritance.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] + overrides result, _err = run_python_script(cmd) @@ -145,7 +145,7 @@ def test_3_config_groups_with_inheritance( def test_4_defaults(tmpdir: Path) -> None: cmd = [ "examples/tutorials/structured_configs/4_defaults/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -168,7 +168,7 @@ def test_4_defaults(tmpdir: Path) -> None: ], ) def test_5_structured_config_schema(tmpdir: Path, path: str) -> None: - cmd = [path, "hydra.run.dir=" + str(tmpdir), "hydra.job.chdir=True"] + cmd = [path, f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True"] result, _err = run_python_script(cmd) assert OmegaConf.create(result) == { "db": { diff --git a/tests/test_examples/test_tutorials_basic.py b/tests/test_examples/test_tutorials_basic.py index 05e2bf047a5..f80fd17d6cb 100644 --- a/tests/test_examples/test_tutorials_basic.py +++ b/tests/test_examples/test_tutorials_basic.py @@ -38,7 +38,7 @@ def test_tutorial_simple_cli_app( ) -> None: cmd = [ "examples/tutorials/basic/your_first_hydra_app/1_simple_cli/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] cmd.extend(args) @@ -49,7 +49,7 @@ def test_tutorial_simple_cli_app( def test_tutorial_working_directory(tmpdir: Path) -> None: cmd = [ "examples/tutorials/basic/running_your_hydra_app/3_working_directory/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -60,7 +60,7 @@ def test_tutorial_working_directory(tmpdir: Path) -> None: def test_tutorial_working_directory_original_cwd(tmpdir: Path) -> None: cmd = [ "examples/tutorials/basic/running_your_hydra_app/3_working_directory/original_cwd.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -87,7 +87,7 @@ def test_tutorial_working_directory_original_cwd(tmpdir: Path) -> None: def test_tutorial_logging(tmpdir: Path, args: List[str], expected: List[str]) -> None: cmd = [ "examples/tutorials/basic/running_your_hydra_app/4_logging/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] cmd.extend(args) @@ -112,7 +112,7 @@ def test_tutorial_logging(tmpdir: Path, args: List[str], expected: List[str]) -> def test_tutorial_config_file(tmpdir: Path, args: List[str], output_conf: Any) -> None: cmd = [ "examples/tutorials/basic/your_first_hydra_app/2_config_file/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] cmd.extend(args) @@ -139,7 +139,7 @@ def test_tutorial_config_file_bad_key( cmd = [ "examples/tutorials/basic/your_first_hydra_app/2_config_file/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] cmd.extend(args) @@ -175,7 +175,7 @@ def test_tutorial_config_groups( ) -> None: cmd = [ "examples/tutorials/basic/your_first_hydra_app/4_config_groups/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] cmd.extend(args) @@ -214,7 +214,7 @@ def test_tutorial_config_groups( def test_tutorial_defaults(tmpdir: Path, args: List[str], expected: DictConfig) -> None: cmd = [ "examples/tutorials/basic/your_first_hydra_app/5_defaults/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] cmd.extend(args) @@ -316,7 +316,7 @@ def test_advanced_ad_hoc_composition( monkeypatch.setenv("USER", "test_user") cmd = [ "examples/advanced/ad_hoc_composition/hydra_compose_example.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -326,7 +326,7 @@ def test_advanced_ad_hoc_composition( def test_examples_using_the_config_object(tmpdir: Path) -> None: cmd = [ "examples/tutorials/basic/your_first_hydra_app/3_using_config/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] diff --git a/tests/test_hydra.py b/tests/test_hydra.py index 2dd0232a529..0357c5065f1 100644 --- a/tests/test_hydra.py +++ b/tests/test_hydra.py @@ -374,7 +374,7 @@ def test_app_with_sweep_cfg__override_to_basic_launcher( def test_short_module_name(tmpdir: Path) -> None: cmd = [ "examples/tutorials/basic/your_first_hydra_app/2_config_file/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] out, _err = run_python_script(cmd) @@ -404,7 +404,7 @@ def test_module_env_override(tmpdir: Path, env_name: str) -> None: """ cmd = [ "examples/tutorials/basic/your_first_hydra_app/2_config_file/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] modified_env = os.environ.copy() @@ -421,7 +421,7 @@ def test_module_env_override(tmpdir: Path, env_name: str) -> None: def test_cfg(tmpdir: Path, flag: str, resolve: bool, expected_keys: List[str]) -> None: cmd = [ "examples/tutorials/basic/your_first_hydra_app/5_defaults/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", flag, ] @@ -481,7 +481,7 @@ def test_cfg_with_package( ) -> None: cmd = [ "examples/tutorials/basic/your_first_hydra_app/5_defaults/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] + flags if resolve: @@ -539,7 +539,7 @@ def test_cfg_resolve_interpolation( ) -> None: cmd = [ script, - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "--cfg=job", ] + flags @@ -570,7 +570,7 @@ def test_pass_callable_class_to_hydra_main( ) -> None: cmd = [ script, - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] @@ -585,7 +585,7 @@ def test_pass_callable_class_to_hydra_main( def test_resolve_flag_errmsg(tmpdir: Path, other_flag: Optional[str]) -> None: cmd = [ "examples/tutorials/basic/your_first_hydra_app/3_using_config/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", "--resolve", ] @@ -834,7 +834,7 @@ def test_sweep_complex_defaults( def test_help( tmpdir: Path, script: str, flags: List[str], overrides: List[str], expected: Any ) -> None: - cmd = [script, "hydra.run.dir=" + str(tmpdir), "hydra.job.chdir=True"] + cmd = [script, f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True"] cmd.extend(overrides) cmd.extend(flags) result, _err = run_python_script(cmd) @@ -864,7 +864,7 @@ def test_help( def test_searchpath_config(tmpdir: Path, overrides: List[str], expected: str) -> None: cmd = ["examples/advanced/config_search_path/my_app.py"] cmd.extend(overrides) - cmd.extend(["hydra.run.dir=" + str(tmpdir), "hydra.job.chdir=True"]) + cmd.extend([f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True"]) result, _err = run_python_script(cmd) assert re.match(expected, result, re.DOTALL) @@ -900,7 +900,7 @@ def test_sys_exit(tmpdir: Path) -> None: sys.executable, "-Werror", "tests/test_apps/sys_exit/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] assert subprocess.run(cmd).returncode == 42 @@ -1047,7 +1047,7 @@ def test_config_name_and_path_overrides( ) -> None: cmd = [ "tests/test_apps/app_with_multiple_config_dirs/my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", f"--config-name={config_name}", f"--config-path={config_path}", @@ -1113,7 +1113,7 @@ def test_module_run( ) -> None: cmd = [ directory + "/" + file, - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] modified_env = os.environ.copy() @@ -1340,7 +1340,7 @@ def test_config_dir_argument( monkeypatch.chdir("tests/test_apps/user-config-dir") cmd = [ "my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] cmd.extend(overrides) @@ -1352,7 +1352,7 @@ def test_schema_overrides_hydra(monkeypatch: Any, tmpdir: Path) -> None: monkeypatch.chdir("tests/test_apps/schema_overrides_hydra") cmd = [ "my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -1363,7 +1363,7 @@ def test_defaults_pkg_with_dot(monkeypatch: Any, tmpdir: Path) -> None: monkeypatch.chdir("tests/test_apps/defaults_pkg_with_dot") cmd = [ "my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -1414,7 +1414,7 @@ def test_job_exception( ret = run_with_error( [ "tests/test_apps/app_exception/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] ) @@ -1425,7 +1425,7 @@ def test_job_exception_full_error(tmpdir: Any) -> None: ret = run_with_error( [ "tests/test_apps/app_exception/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ], env={**os.environ, "HYDRA_FULL_ERROR": "1"}, @@ -1439,7 +1439,7 @@ def test_structured_with_none_list(monkeypatch: Any, tmpdir: Path) -> None: monkeypatch.chdir("tests/test_apps/structured_with_none_list") cmd = [ "my_app.py", - "hydra.run.dir=" + str(tmpdir), + f'hydra.run.dir="{str(tmpdir)}"', "hydra.job.chdir=True", ] result, _err = run_python_script(cmd) @@ -1471,7 +1471,7 @@ def test_job_id_and_num_in_sweep(tmpdir: Path) -> None: def test_hydra_main_without_config_path(tmpdir: Path) -> None: cmd = [ "tests/test_apps/hydra_main_without_config_path/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] _, err = run_python_script(cmd, allow_warnings=True) @@ -1500,7 +1500,7 @@ def test_hydra_main_without_config_path(tmpdir: Path) -> None: def test_job_chdir_not_specified(tmpdir: Path) -> None: cmd = [ "tests/test_apps/app_with_no_chdir_override/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', ] out, err = run_python_script(cmd, allow_warnings=True) @@ -1522,7 +1522,7 @@ def test_job_chdir_not_specified(tmpdir: Path) -> None: def test_app_with_unicode_config(tmpdir: Path) -> None: cmd = [ "tests/test_apps/app_with_unicode_in_config/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] out, _ = run_python_script(cmd) @@ -1546,7 +1546,7 @@ def test_frozen_primary_config( ) -> None: cmd = [ "examples/patterns/write_protect_config_node/frozen.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] cmd.extend(overrides) @@ -1586,7 +1586,7 @@ def test_hydra_deprecation_warning( ) -> None: cmd = [ "tests/test_apps/deprecation_warning/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", ] env = os.environ.copy() @@ -1608,7 +1608,7 @@ def test_hydra_deprecation_warning( def test_disable_chdir(tmpdir: Path, multirun: bool, expected: List[str]) -> None: cmd = [ "examples/tutorials/basic/running_your_hydra_app/3_working_directory/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', f"hydra.sweep.dir={tmpdir}", "hydra.job.chdir=False", ] @@ -1628,7 +1628,7 @@ def test_disable_chdir(tmpdir: Path, multirun: bool, expected: List[str]) -> Non def test_disable_chdir_with_app_chdir(tmpdir: Path, chdir: bool) -> None: cmd = [ "tests/test_apps/app_change_dir/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', f"hydra.job.chdir={chdir}", ] result, _err = run_python_script(cmd) @@ -1643,7 +1643,7 @@ def test_disable_chdir_with_app_chdir(tmpdir: Path, chdir: bool) -> None: def test_hydra_verbose_1897(tmpdir: Path, multirun: bool) -> None: cmd = [ "tests/test_apps/hydra_verbose/my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=False", ] if multirun: diff --git a/tools/ci/circleci_pipeline.py b/tools/ci/circleci_pipeline.py deleted file mode 100644 index 56ccba9aa3e..00000000000 --- a/tools/ci/circleci_pipeline.py +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved -# type: ignore -import json -import os -import random -import re -from itertools import islice -from os.path import dirname -from typing import List - -import requests - -git_repo_pattern = ( - r"((git|ssh|http(s)?)|(git@[\w\.]+))(:(//)?)([\w\.@\:/\-~]+)(\.git)(/)?" -) - -BASE = dirname(dirname(os.path.abspath(os.path.dirname(__file__)))) - -# a list of plugins that should be its own test suite -# could be due to dependency or time to run the test -test_alone_plugins = ["hydra_ray_launcher"] - - -def chunk(it, size): - it = iter(it) - return iter(lambda: tuple(islice(it, size)), ()) - - -def get_available_plugin() -> List[str]: - skip = [".isort.cfg"] - skip.extend(test_alone_plugins) - - ps = [ - {"dir_name": x, "path": x} - for x in sorted(os.listdir(os.path.join(BASE, "plugins"))) - if x not in skip - ] - plugins = [p["path"] for p in ps] - random.shuffle(plugins) - groups_of_plugins = [",".join(w) for w in list(chunk(plugins, 4))] - groups_of_plugins.extend(test_alone_plugins) - return groups_of_plugins - - -def run() -> None: - auth = os.environ.get("CIRCLECI_TOKEN", "0") - assert auth != "0", "Please set CIRCLECI_TOKEN for your project." - - branch = os.environ.get("CIRCLE_BRANCH", "") - repo_url = os.environ.get("CIRCLE_REPOSITORY_URL", "") - pr_number = os.environ.get("CIRCLE_PR_NUMBER", "") - - # https://support.circleci.com/hc/en-us/articles/360049841151 - if pr_number: - branch += "/head" - p = re.compile(git_repo_pattern) - m = re.search(p, repo_url) - repo_name = m.group(m.groups().index(".git")) - headers = {"Circle-Token": auth, "Content-type": "application/json"} - - for p in get_available_plugin(): - data = { - "branch": branch, - "parameters": {"test_plugins": p, "plugin_test": True}, - } - post_url = f"https://circleci.com/api/v2/project/gh/{repo_name}/pipeline" - print(f"Data: {data}, URL: {post_url}") - r = requests.post( - post_url, - headers=headers, - data=json.dumps(data), - timeout=60, - ) - assert ( - r.status_code == 201 - ), f"Unexpected response while submitting CIRCLECI job for plugins. Response: {r.json()}" - print(f"Trigger pipeline for plugin {p}, response: {r.json()}") - - -if __name__ == "__main__": - run() diff --git a/tools/configen/tests/test_generate.py b/tools/configen/tests/test_generate.py index 701d5195a25..e59c2917f7f 100644 --- a/tools/configen/tests/test_generate.py +++ b/tools/configen/tests/test_generate.py @@ -1,36 +1,36 @@ # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved import sys -from textwrap import dedent from difflib import unified_diff from pathlib import Path +from textwrap import dedent from typing import Any -from pytest import mark, param +from configen.config import ConfigenConf, Flags, ModuleConf +from configen.configen import generate_module +from hydra.test_utils.test_utils import chdir_hydra_root, run_python_script -from hydra.utils import get_class, instantiate, ConvertMode +from hydra.utils import ConvertMode, get_class, instantiate from omegaconf import OmegaConf -from configen.config import ConfigenConf, ModuleConf, Flags -from configen.configen import generate_module -from hydra.test_utils.test_utils import chdir_hydra_root, run_python_script +from pytest import mark, param from tests.test_modules import ( - User, Color, + DictValues, Empty, - UntypedArg, + IncompatibleDataclass, + IncompatibleDataclassArg, IntArg, - UnionArg, - WithLibraryClassArg, LibraryClass, - IncompatibleDataclassArg, - IncompatibleDataclass, - WithStringDefault, - WithUntypedStringDefault, ListValues, - DictValues, PeskySentinelUsage, Tuples, + UnionArg, + UntypedArg, + User, + WithLibraryClassArg, + WithStringDefault, + WithUntypedStringDefault, ) from tests.test_modules.generated import PeskySentinelUsageConf @@ -288,7 +288,7 @@ def test_example_application(monkeypatch: Any, tmpdir: Path): monkeypatch.chdir("example") cmd = [ "my_app.py", - f"hydra.run.dir={tmpdir}", + f'hydra.run.dir="{tmpdir}"', "hydra.job.chdir=True", "user.name=Batman", ]