diff --git a/README.md b/README.md index 8dc9534..157d0a6 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ There are a few backward incompatibilities that you should be aware of: - The `SPACY_CONFIG_OVERRIDES` environment variable is no longer checked. You can set configuration overrides using `WEASEL_CONFIG_OVERRIDES`. - Support for the `spacy_version` configuration key has been dropped. +- Support for the `check_requirements` configuration key has been dropped. - Support for `SPACY_PROJECT_USE_GIT_VERSION` environment variable has been dropped. - Error codes are now Weasel-specific, and do not follow spaCy error codes. diff --git a/docs/tutorial/directory-and-assets.md b/docs/tutorial/directory-and-assets.md index 30e7fdb..43216a1 100644 --- a/docs/tutorial/directory-and-assets.md +++ b/docs/tutorial/directory-and-assets.md @@ -57,7 +57,6 @@ pipelines. | `assets` | A list of assets that can be fetched with the [`assets`](../cli.md#open_file_folder-assets) command. `url` defines a URL or local path, `dest` is the destination file relative to the project directory, and an optional `checksum` ensures that an error is raised if the file's checksum doesn't match. Instead of `url`, you can also provide a `git` block with the keys `repo`, `branch` and `path`, to download from a Git repo. | | `workflows` | A dictionary of workflow names, mapped to a list of command names, to execute in order. Workflows can be run with the [`run`](../cli.md#rocket-run) command. | | `commands` | A list of named commands. A command can define an optional help message (shown in the CLI when the user adds `--help`) and the `script`, a list of commands to run. The `deps` and `outputs` let you define the created file the command depends on and produces, respectively. This lets Weasel determine whether a command needs to be re-run because its dependencies or outputs changed. Commands can be run as part of a workflow, or separately with the [`run`](../cli.md#rocket-run) command. | -| `check_requirements` | A flag determining whether to verify that the installed dependencies align with the project's `requirements.txt`. Defaults to `true`. | ## Data assets diff --git a/docs/tutorial/workflow.md b/docs/tutorial/workflow.md index 4463f77..552e26f 100644 --- a/docs/tutorial/workflow.md +++ b/docs/tutorial/workflow.md @@ -99,13 +99,6 @@ skipped. You can also set `--force` to force re-running a command, or `--dry` to perform a "dry run" and see what would happen (without actually running the script). -`weasels run` checks your installed dependencies to -verify that your environment is properly set up and aligns with the project's -`requirements.txt`, if there is one. If missing or conflicting dependencies are -detected, a corresponding warning is displayed. If you'd like to disable the -dependency check, set `check_requirements: false` in your project's -`project.yml`. - ## 4. Run a workflow Workflows are series of commands that are run in order and often depend on each diff --git a/weasel/cli/run.py b/weasel/cli/run.py index 73b9542..ce0b2cf 100644 --- a/weasel/cli/run.py +++ b/weasel/cli/run.py @@ -1,7 +1,6 @@ -import os.path import sys from pathlib import Path -from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple +from typing import Any, Dict, Iterable, List, Optional, Sequence import srsly import typer @@ -66,19 +65,13 @@ def project_run( sys.exit will be called with the return code. You should use capture=False when you want to turn over execution to the command, and capture=True when you want to run the command more like a function. - skip_requirements_check (bool): Whether to skip the requirements check. + skip_requirements_check (bool): No longer used, deprecated. """ config = load_project_config(project_dir, overrides=overrides) commands = {cmd["name"]: cmd for cmd in config.get("commands", [])} workflows = config.get("workflows", {}) validate_subcommand(list(commands.keys()), list(workflows.keys()), subcommand) - req_path = project_dir / "requirements.txt" - if not skip_requirements_check: - if config.get("check_requirements", True) and os.path.exists(req_path): - with req_path.open() as requirements_file: - _check_requirements([req.strip() for req in requirements_file]) - if subcommand in workflows: msg.info(f"Running workflow '{subcommand}'") for cmd in workflows[subcommand]: @@ -89,7 +82,6 @@ def project_run( force=force, dry=dry, capture=capture, - skip_requirements_check=True, ) else: cmd = commands[subcommand] @@ -302,39 +294,3 @@ def get_fileinfo(project_dir: Path, paths: List[str]) -> List[Dict[str, Optional md5 = get_checksum(file_path) if file_path.exists() else None data.append({"path": path, "md5": md5}) return data - - -def _check_requirements(requirements: List[str]) -> Tuple[bool, bool]: - """Checks whether requirements are installed and free of version conflicts. - requirements (List[str]): List of requirements. - RETURNS (Tuple[bool, bool]): Whether (1) any packages couldn't be imported, (2) any packages with version conflicts - exist. - """ - import pkg_resources - - failed_pkgs_msgs: List[str] = [] - conflicting_pkgs_msgs: List[str] = [] - - for req in requirements: - try: - pkg_resources.require(req) - except pkg_resources.DistributionNotFound as dnf: - failed_pkgs_msgs.append(dnf.report()) - except pkg_resources.VersionConflict as vc: - conflicting_pkgs_msgs.append(vc.report()) - except Exception: - msg.warn( - f"Unable to check requirement: {req} " - "Checks are currently limited to requirement specifiers " - "(PEP 508)" - ) - - if len(failed_pkgs_msgs) or len(conflicting_pkgs_msgs): - msg.warn( - title="Missing requirements or requirement conflicts detected. Make sure your Python environment is set up " - "correctly and you installed all requirements specified in your project's requirements.txt: " - ) - for pgk_msg in failed_pkgs_msgs + conflicting_pkgs_msgs: - msg.text(pgk_msg) - - return len(failed_pkgs_msgs) > 0, len(conflicting_pkgs_msgs) > 0 diff --git a/weasel/schemas.py b/weasel/schemas.py index 887fde4..9563417 100644 --- a/weasel/schemas.py +++ b/weasel/schemas.py @@ -92,4 +92,9 @@ def check_legacy_keys(cls, obj: Dict[str, Any]) -> Dict[str, Any]: "Your project configuration file includes a `spacy_version` key, " "which is now deprecated. Weasel will not validate your version of spaCy.", ) + if "check_requirements" in obj: + msg.warn( + "Your project configuration file includes a `check_requirements` key, " + "which is now deprecated. Weasel will not validate your requirements.", + ) return obj diff --git a/weasel/tests/cli/test_cli.py b/weasel/tests/cli/test_cli.py index 968ea58..9e89534 100644 --- a/weasel/tests/cli/test_cli.py +++ b/weasel/tests/cli/test_cli.py @@ -5,7 +5,6 @@ import srsly from weasel.cli.remote_storage import RemoteStorage -from weasel.cli.run import _check_requirements from weasel.schemas import ProjectConfigSchema, validate from weasel.util import is_subpath_of, load_project_config, make_tempdir from weasel.util import validate_project_commands @@ -166,45 +165,3 @@ def test_local_remote_storage_pull_missing(): remote = RemoteStorage(d / "root", str(d / "remote")) assert remote.pull(filename, command_hash="aaaa") is None assert remote.pull(filename) is None - - -@pytest.mark.filterwarnings("ignore::DeprecationWarning") -@pytest.mark.parametrize( - "reqs,output", - [ - [ - """ - weasel - - # comment - - confection""", - (False, False), - ], - [ - """# comment - --some-flag - weasel""", - (False, False), - ], - [ - """# comment - --some-flag - weasel; python_version >= '3.6'""", - (False, False), - ], - [ - """# comment - spacyunknowndoesnotexist12345""", - (True, False), - ], - ], -) -def test_project_check_requirements(reqs, output): - import pkg_resources - - # excessive guard against unlikely package name - try: - pkg_resources.require("spacyunknowndoesnotexist12345") - except pkg_resources.DistributionNotFound: - assert output == _check_requirements([req.strip() for req in reqs.split("\n")])