mirror of
https://github.com/explosion/spaCy.git
synced 2025-08-08 14:14:57 +03:00
Remove join_command
Also fixes issue with run_commands on Windows.
This commit is contained in:
parent
0f1d97d87d
commit
65ad661914
|
@ -7,7 +7,7 @@ from wasabi import msg
|
|||
|
||||
from .._util import PROJECT_FILE, load_project_config, get_hash, project_cli
|
||||
from .._util import Arg, Opt, NAME, COMMAND
|
||||
from ...util import working_dir, join_command, run_command
|
||||
from ...util import working_dir, run_command
|
||||
from ...util import SimpleFrozenList
|
||||
|
||||
|
||||
|
@ -122,7 +122,7 @@ def update_dvc_config(
|
|||
if command.get("no_skip"):
|
||||
dvc_cmd.append("--always-changed")
|
||||
full_cmd = [*dvc_cmd, *deps_cmd, *outputs_cmd, *outputs_nc_cmd, *project_cmd]
|
||||
dvc_commands.append(join_command(full_cmd))
|
||||
dvc_commands.append(full_cmd)
|
||||
with working_dir(path):
|
||||
dvc_flags = {"--verbose": verbose, "--quiet": silent}
|
||||
run_dvc_commands(dvc_commands, flags=dvc_flags)
|
||||
|
@ -134,21 +134,20 @@ def update_dvc_config(
|
|||
|
||||
|
||||
def run_dvc_commands(
|
||||
commands: Iterable[str] = SimpleFrozenList(), flags: Dict[str, bool] = {}
|
||||
commands: Iterable[List[str]] = SimpleFrozenList(), flags: Dict[str, bool] = {}
|
||||
) -> None:
|
||||
"""Run a sequence of DVC commands in a subprocess, in order.
|
||||
|
||||
commands (List[str]): The string commands without the leading "dvc".
|
||||
commands (List[List[str]]): The string commands without the leading "dvc".
|
||||
flags (Dict[str, bool]): Conditional flags to be added to command. Makes it
|
||||
easier to pass flags like --quiet that depend on a variable or
|
||||
command-line setting while avoiding lots of nested conditionals.
|
||||
"""
|
||||
for c in commands:
|
||||
dvc_command = "dvc " + c
|
||||
dvc_command = ["dvc", *c]
|
||||
# Add the flags if they are set to True
|
||||
for flag, is_active in flags.items():
|
||||
if is_active:
|
||||
dvc_command += " " + flag
|
||||
dvc_command.append(flag)
|
||||
run_command(dvc_command)
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import typer
|
|||
from ... import about
|
||||
from ...git_info import GIT_VERSION
|
||||
from ...compat import is_windows
|
||||
from ...util import working_dir, run_command, is_cwd, join_command
|
||||
from ...util import working_dir, run_command, is_cwd
|
||||
from ...util import SimpleFrozenList, is_minor_version_match, ENV_VARS
|
||||
from ...util import check_bool_env_var, SimpleFrozenDict
|
||||
from .._util import PROJECT_FILE, PROJECT_LOCK, load_project_config, get_hash
|
||||
|
@ -170,6 +170,7 @@ def run_commands(
|
|||
if is_windows:
|
||||
# On Windows we don't rewrite the command because there's no
|
||||
# reliable way to split and reassemble it
|
||||
command = c
|
||||
if not silent:
|
||||
print(f"Running command: {c}")
|
||||
else:
|
||||
|
@ -186,7 +187,7 @@ def run_commands(
|
|||
elif len(command) and command[0] in ("pip", "pip3"):
|
||||
command = [sys.executable, "-m", "pip", *command[1:]]
|
||||
if not silent:
|
||||
print(f"Running command: {join_command(command)}")
|
||||
print(f"Running command: {c}")
|
||||
|
||||
if not dry:
|
||||
run_command(command, capture=capture)
|
||||
|
|
|
@ -936,16 +936,6 @@ def replace_model_node(model: Model, target: Model, replacement: Model) -> None:
|
|||
node.set_ref(ref_name, replacement)
|
||||
|
||||
|
||||
def join_command(command: List[str]) -> str:
|
||||
"""Join a command using shlex. shlex.join is only available for Python 3.8+,
|
||||
so we're using a workaround here.
|
||||
|
||||
command (List[str]): The command to join.
|
||||
RETURNS (str): The joined command
|
||||
"""
|
||||
return " ".join(shlex.quote(cmd) for cmd in command)
|
||||
|
||||
|
||||
def run_command(
|
||||
command: Union[str, List[str]],
|
||||
*,
|
||||
|
|
Loading…
Reference in New Issue
Block a user