Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sophie-katz committed Aug 11, 2023
1 parent ee82df8 commit 9a08ed3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion template/pyproject.toml.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ lockfile = { shell = "python3 scripts/pdm_lockfile.py" }
"lint:pycodestyle" = { shell = "pycodestyle --ignore E501,W503,E261 {{ module_name }}" }
"lint:pydocstyle" = { shell = "pydocstyle {{ module_name }}" }
"lint:bandit" = { shell = "bandit -s B101 -r {{ module_name }}" }
"lint:vulture" = { shell = "vulture {{ module_name }}" }
"lint:vulture" = { shell = "vulture --ignore-names model_config,comet_enabled,comet_api_key,comet_project_name,comet_workspace,create_experiment {{ module_name }}" }
"lint:isort" = { shell = "isort -c {{ module_name }}" }
lint = { composite = [
"lint:mypy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

from typing import Optional

from comet_ml import Experiment
# pycodestyle: disable=E621
from comet_ml import Experiment # type: ignore

from ..settings import Settings


def create_experiment(settings: Settings) -> Optional[Experiment]:
"""Create a Comet experiment.

Arguments
=========
settings: Settings
Expand Down
45 changes: 39 additions & 6 deletions tests/test_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def _create_data_base(


def _create_data_minimal(license: str, python_version: str) -> Dict[str, str]:
base = _create_data_base(license, python_version, "not_applicable")
base = _create_data_base(license, python_version, "default")

base["use_pytorch"] = "false"
base["use_tensorflow"] = "false"
Expand Down Expand Up @@ -189,7 +189,7 @@ def _create_directory_test_minimal(license: str, cuda_version: str) -> Directory
]
),
".pdm-python": FileTest(),
f"pdm.{sys.platform}.{('default' if cuda_version == 'not_applicable' else cuda_version)}.lock": FileTest(),
f"pdm.{sys.platform}.{('default' if cuda_version == 'default' else cuda_version)}.lock": FileTest(),
"pdm.lock": FileTest(),
"pyproject.toml": FileTest(
on_text=[
Expand Down Expand Up @@ -221,7 +221,21 @@ def _create_directory_test_minimal(license: str, cuda_version: str) -> Directory
"__pypackages__": DirectoryTest(ignore_children=True, optional=True),
"language_model": DirectoryTest(
child_files={
"__init__.py": FileTest(on_text=[_test_file_empty]),
"__init__.py": FileTest(
on_text=[
lambda text: _test_file_starts_with_license_hashes(
license != "none", text
),
lambda text: _test_file_license_content(license, text),
lambda text: _test_file_two_newlines_after_license_hashes(
license != "none", text
),
_test_file_python_version_with_dot,
],
on_path=[
_test_file_formatting_black,
],
),
"settings.py": FileTest(
on_text=[
lambda text: _test_file_starts_with_license_hashes(
Expand Down Expand Up @@ -340,7 +354,23 @@ def _create_directory_test_minimal(license: str, cuda_version: str) -> Directory
_test_file_formatting_black,
],
),
"__init__.py": FileTest(on_text=[_test_file_empty]),
"__init__.py": FileTest(
on_text=[
lambda text: _test_file_starts_with_license_hashes(
license != "none", text
),
lambda text: _test_file_license_content(
license, text
),
lambda text: _test_file_two_newlines_after_license_hashes(
license != "none", text
),
_test_file_python_version_with_dot,
],
on_path=[
_test_file_formatting_black,
],
),
}
)
},
Expand Down Expand Up @@ -438,7 +468,10 @@ def _run_copy_test(

assert result.returncode == 0

result = subprocess.run(["pdm", "run", "lint:vulture"], cwd=copy_directory)
result = subprocess.run(
["pdm", "run", "lint:vulture"],
cwd=copy_directory,
)

assert result.returncode == 0

Expand Down Expand Up @@ -493,7 +526,7 @@ def test_minimal(license: str, python_version: str) -> None:
_run_copy_test(
copy_name=f"minimal-{license}-{python_version}",
data=_create_data_minimal(license=license, python_version=python_version),
directory_test=_create_directory_test_minimal(license, "not_applicable"),
directory_test=_create_directory_test_minimal(license, "default"),
)


Expand Down

0 comments on commit 9a08ed3

Please sign in to comment.