Skip to content

Commit

Permalink
Merge pull request #87 from fal-ai/use-proper-debug-level
Browse files Browse the repository at this point in the history
misc: use level=info for build-related outputs
  • Loading branch information
isidentical authored Mar 16, 2023
2 parents eacc6f7 + a6df77c commit f6c6816
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
4 changes: 3 additions & 1 deletion src/isolate/backends/conda.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import subprocess
import tempfile
from dataclasses import dataclass, field
from functools import partial
from pathlib import Path
from typing import Any, ClassVar, Dict, List, Optional, Union

Expand All @@ -19,6 +20,7 @@
)
from isolate.backends.settings import DEFAULT_SETTINGS, IsolateSettings
from isolate.connections import PythonIPC
from isolate.logs import LogLevel

# Specify the path where the conda binary might reside in (or
# mamba, if it is the preferred one).
Expand Down Expand Up @@ -147,7 +149,7 @@ def destroy(self, connection_key: Path) -> None:

def _run_conda(self, *args: Any) -> None:
conda_executable = _get_conda_executable()
with logged_io(self.log) as (stdout, stderr):
with logged_io(partial(self.log, level=LogLevel.INFO)) as (stdout, stderr):
subprocess.check_call(
[conda_executable, *args],
stdout=stdout,
Expand Down
10 changes: 6 additions & 4 deletions src/isolate/backends/pyenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
import os
import shutil
import subprocess
from dataclasses import dataclass, field
from dataclasses import dataclass
from functools import partial
from pathlib import Path
from typing import Any, ClassVar, Dict, List, Optional
from typing import Any, ClassVar, Dict, Optional

from isolate.backends import BaseEnvironment, EnvironmentCreationError
from isolate.backends.common import active_python, logged_io, sha256_digest_of
from isolate.backends.common import logged_io
from isolate.backends.settings import DEFAULT_SETTINGS, IsolateSettings
from isolate.connections import PythonIPC
from isolate.logs import LogLevel

_PYENV_EXECUTABLE_NAME = "pyenv"
_PYENV_EXECUTABLE_PATH = os.environ.get("ISOLATE_PYENV_EXECUTABLE")
Expand Down Expand Up @@ -77,7 +79,7 @@ def _try_get_prefix(self, pyenv: Path, root_path: Path) -> Optional[Path]:
return Path(prefix.strip())

def _install_python(self, pyenv: Path, root_path: Path) -> None:
with logged_io(self.log) as (stdout, stderr):
with logged_io(partial(self.log, level=LogLevel.INFO)) as (stdout, stderr):
try:
subprocess.check_call(
[pyenv, "install", "--skip-existing", self.python_version],
Expand Down
4 changes: 3 additions & 1 deletion src/isolate/backends/virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import shutil
import subprocess
from dataclasses import dataclass, field
from functools import partial
from pathlib import Path
from typing import Any, ClassVar, Dict, List, Optional, Union

Expand All @@ -17,6 +18,7 @@
)
from isolate.backends.settings import DEFAULT_SETTINGS, IsolateSettings
from isolate.connections import PythonIPC
from isolate.logs import LogLevel


@dataclass
Expand Down Expand Up @@ -77,7 +79,7 @@ def install_requirements(self, path: Path) -> None:
for extra_index_url in self.extra_index_urls:
pip_cmd.extend(["--extra-index-url", extra_index_url])

with logged_io(self.log) as (stdout, stderr):
with logged_io(partial(self.log, level=LogLevel.INFO)) as (stdout, stderr):
try:
subprocess.check_call(
pip_cmd,
Expand Down
14 changes: 7 additions & 7 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ def test_executable_running(self, tmp_path):
assert py_version.startswith("Python 3")

def test_self_installed_executable_running(self, tmp_path):
environment = self.get_project_environment(tmp_path, "dbt-core")
environment = self.get_project_environment(tmp_path, "black")
with environment.connect() as connection:
dbt_version = self._run_cmd(connection, "dbt", "--version")
assert "installed: 1.3.1" in dbt_version
black_version = self._run_cmd(connection, "black", "--version")
assert "black, 22.12.0" in black_version

def test_custom_python_version(self, tmp_path):
for python_type, python_version in [
Expand Down Expand Up @@ -225,8 +225,8 @@ class TestVirtualenv(GenericEnvironmentTests):
"example-binary": {
"requirements": [],
},
"dbt-core": {
"requirements": ["dbt-core==1.3.1"],
"black": {
"requirements": ["black==22.12.0"],
},
"old-python": {
"python_version": "3.7",
Expand Down Expand Up @@ -389,8 +389,8 @@ class TestConda(GenericEnvironmentTests):
"example-binary": {
"packages": [],
},
"dbt-core": {
"packages": ["dbt-core=1.3.1"],
"black": {
"packages": ["black=22.12.0"],
},
"old-python": {
"python_version": "3.7",
Expand Down

0 comments on commit f6c6816

Please sign in to comment.