Compare commits

...
19 Commits
Author SHA1 Message Date
Ruslan Kuprieiev 4082757aa1 dvc: bump to 1.11.7 2020-12-15 19:55:12 +02:00
mergify[bot]andJoão Rafael 8a11595a93 Remove version restriction from networkx (#5110) (#5112)
(cherry picked from commit 84a3a59bc7)

Co-authored-by: João Rafael <[email protected]>
2020-12-15 19:54:25 +02:00
Ruslan Kuprieiev 60546dcd98 dvc: bump to 1.11.6 2020-12-14 20:24:50 +02:00
mergify[bot]andpeper0 1b4326aefd fix making too many ssh connections when pushing run cache (#4732) (#4733) (#5097)
* fix making too many ssh connections when pushing run cache (#4732)

* reformat

* generator should exit on GeneratorExit exception

* Update dvc/tree/ssh/__init__.py

* pool: close on Exception and not BaseException

Co-authored-by: Tomasz Łakota <[email protected]>
Co-authored-by: Ruslan Kuprieiev <[email protected]>
Co-authored-by: Ruslan Kuprieiev <[email protected]>
(cherry picked from commit 6e92352001)

Co-authored-by: peper0 <[email protected]>
2020-12-14 16:55:18 +02:00
Ruslan Kuprieiev 1138afe495 dvc: bump to 1.11.5 2020-12-14 13:11:06 +02:00
Ruslan Kuprieiev 7916ce4bfb cli: config: check name format (#5094)
Currently we don't handle bad name well:

```
(dvc-3.8.3) ➜  dvc git:(config-bug) ✗ dvc config section
ERROR: unexpected error - not enough values to unpack (expected 2, got 1)
```

With this PR, we check name to conform to either `remote.name.option` or
`section.option`, so we'll give a more friendly:

```
(dvc-3.8.3) ➜  dvc git:(config-bug) ✗ dvc config section
ERROR: argument name: name argument should look like remote.name.option or section.option
usage: dvc config [-h] [--global | --system | --local] [-q | -v] [-u] [-l] [name] [value]

Get or set config options.
Documentation: <https://man.dvc.org/config>

positional arguments:
  name           Option name (remote.name.option or section.option).
  value          Option value.

optional arguments:
  -h, --help     show this help message and exit
  --global       Use global config.
  --system       Use system config.
  --local        Use local config.
  -q, --quiet    Be quiet.
  -v, --verbose  Be verbose.
  -u, --unset    Unset option.
  -l, --list     List all defined config values.
```
2020-12-14 13:10:11 +02:00
Ruslan Kuprieiev c5db57900d gha: run tests on other branches 2020-12-14 12:37:06 +02:00
Ruslan Kuprieiev c9ef5d3ccb dvc: bump to 1.11.4 2020-12-13 02:33:04 +02:00
Ruslan Kuprieiev cd72149b5f system: _reflink_darwin: use fsencode for path (#5086)
Fixes #5083
2020-12-13 02:32:37 +02:00
Ruslan Kuprieiev 80c1f10f08 dvc: bump to 1.11.3 2020-12-08 18:09:48 +02:00
Saugat Pachhai 573546d824 Pin numpy for windows build (#5057) 2020-12-08 18:06:38 +02:00
Casper da Costa-Luis 41b20cd675 tidy snap release (#5016) 2020-12-02 20:21:00 +02:00
Ruslan Kuprieiev cb90bd0c8d dvc: bump to 1.11.2 2020-12-02 19:28:15 +02:00
Ruslan Kuprieiev 82896be988 gha: fix snap action name 2020-12-02 19:12:35 +02:00
Ruslan Kuprieiev 84ae8e02f7 snap: fix channels 2020-12-02 19:12:02 +02:00
Ruslan Kuprieiev a97d5fef72 snap: fix channel names 2020-12-02 18:56:16 +02:00
Ruslan Kuprieiev ed02ff7c30 dvc: bump to 1.11.1 2020-12-02 18:28:29 +02:00
Ruslan Kuprieiev 363ad46326 gha: build packages on other branches 2020-12-02 18:07:26 +02:00
Ruslan Kuprieiev 776ed1d2dd snap: publish to v1 channel 2020-12-02 18:06:08 +02:00
11 changed files with 78 additions and 28 deletions
+3 -5
View File
@@ -1,8 +1,6 @@
name: Build packages
on:
push:
branches:
- master
push: {}
release:
types: [released]
jobs:
@@ -121,11 +119,11 @@ jobs:
with:
store_login: ${{ secrets.STORE_LOGIN }}
snap: ${{ steps.snapcraft.outputs.snap }}
release: edge
release: edge,v1/edge
- name: Publish to the stable channel
uses: snapcore/action-publish@v1
if: github.event_name == 'release'
with:
store_login: ${{ secrets.STORE_LOGIN }}
snap: ${{ steps.snapcraft.outputs.snap }}
release: stable
release: stable,v1/stable
+2 -6
View File
@@ -1,12 +1,8 @@
name: Tests
on:
pull_request:
branches:
- master
push:
branches:
- master
- pull_request
- push
env:
DVC_TEST: "true"
+38 -10
View File
@@ -6,6 +6,25 @@ from dvc.config import Config, ConfigError
logger = logging.getLogger(__name__)
NAME_REGEX = r"^(?P<remote>remote\.)?(?P<section>[^\.]*)\.(?P<option>[^\.]*)$"
def _name_type(value):
import re
match = re.match(NAME_REGEX, value)
if not match:
raise argparse.ArgumentTypeError(
"name argument should look like "
"remote.name.option or "
"section.option"
)
return (
bool(match.group("remote")),
match.group("section").lower(),
match.group("option").lower(),
)
class CmdConfig(CmdBaseNoRepo):
def __init__(self, args):
@@ -14,20 +33,24 @@ class CmdConfig(CmdBaseNoRepo):
self.config = Config(validate=False)
def run(self):
section, opt = self.args.name.lower().strip().split(".", 1)
remote, section, opt = self.args.name
if self.args.value is None and not self.args.unset:
conf = self.config.load_one(self.args.level)
self._check(conf, section, opt)
if remote:
conf = conf["remote"]
self._check(conf, remote, section, opt)
logger.info(conf[section][opt])
return 0
with self.config.edit(self.args.level) as conf:
if remote:
conf = conf["remote"]
if self.args.unset:
self._check(conf, section, opt)
self._check(conf, remote, section, opt)
del conf[section][opt]
else:
self._check(conf, section)
self._check(conf, remote, section)
conf[section][opt] = self.args.value
if self.args.name == "cache.type":
@@ -39,14 +62,15 @@ class CmdConfig(CmdBaseNoRepo):
return 0
def _check(self, conf, section, opt=None):
def _check(self, conf, remote, section, opt=None):
name = "remote" if remote else "section"
if section not in conf:
msg = "section {} doesn't exist"
raise ConfigError(msg.format(self.args.name))
raise ConfigError(f"{name} '{section}' doesn't exist")
if opt and opt not in conf[section]:
msg = "option {} doesn't exist"
raise ConfigError(msg.format(self.args.name))
raise ConfigError(
f"option '{opt}' doesn't exist in {name} '{section}'"
)
parent_config_parser = argparse.ArgumentParser(add_help=False)
@@ -92,6 +116,10 @@ def add_parser(subparsers, parent_parser):
action="store_true",
help="Unset option.",
)
config_parser.add_argument("name", help="Option name.")
config_parser.add_argument(
"name",
type=_name_type,
help="Option name (remote.name.option or section.option).",
)
config_parser.add_argument("value", nargs="?", help="Option value.")
config_parser.set_defaults(func=CmdConfig)
+2 -2
View File
@@ -71,8 +71,8 @@ class System:
clonefile.restype = ctypes.c_int
return clonefile(
ctypes.c_char_p(src.encode("utf-8")),
ctypes.c_char_p(dst.encode("utf-8")),
ctypes.c_char_p(os.fsencode(src)),
ctypes.c_char_p(os.fsencode(dst)),
ctypes.c_int(0),
)
+1 -1
View File
@@ -11,7 +11,7 @@ def get_connection(conn_func, *args, **kwargs):
conn = pool.get_connection()
try:
yield conn
except BaseException:
except Exception:
conn.close()
raise
else:
+1 -1
View File
@@ -6,7 +6,7 @@
import os
import subprocess
_BASE_VERSION = "1.11.0"
_BASE_VERSION = "1.11.7"
def _generate_version(base_version):
+1
View File
@@ -1,2 +1,3 @@
PyInstaller==3.5
numpy==1.19.3
psutil
+1 -1
View File
@@ -71,7 +71,7 @@ install_requires = [
"flufl.lock>=3.2,<4",
"win-unicode-console>=0.5; sys_platform == 'win32'",
"pywin32>=225; sys_platform == 'win32'",
"networkx>=2.1,<2.5",
"networkx>=2.1",
"pydot>=1.2.4",
"speedcopy>=2.0.1; python_version < '3.8' and sys_platform == 'win32'",
"dataclasses==0.7; python_version < '3.7'",
+2 -2
View File
@@ -141,14 +141,14 @@ class TestGCMultipleDvcRepos(TestDvc):
class TestConfig(TestDvc):
def test(self):
name = "param"
name = "section.option"
value = "1"
args = parse_args(["config", "-u", "--unset", name, value])
self.assertIsInstance(args.func(args), CmdConfig)
self.assertEqual(args.unset, True)
self.assertEqual(args.name, name)
self.assertEqual(args.name, (False, "section", "option"))
self.assertEqual(args.value, value)
+16
View File
@@ -145,3 +145,19 @@ def test_load_relative_paths(dvc, field, remote_url):
assert cfg["remote"]["test"][field] == os.path.join(
dvc_dir, "..", "file.txt"
)
def test_config_remote(tmp_dir, dvc, caplog):
(tmp_dir / ".dvc" / "config").write_text(
"['remote \"myremote\"']\n"
" url = s3://bucket/path\n"
" region = myregion\n"
)
caplog.clear()
assert main(["config", "remote.myremote.url"]) == 0
assert "s3://bucket/path" in caplog.text
caplog.clear()
assert main(["config", "remote.myremote.region"]) == 0
assert "myregion" in caplog.text
+11
View File
@@ -0,0 +1,11 @@
import pytest
from dvc.cli import DvcParserError, parse_args
@pytest.mark.parametrize(
"name", ["way.too.long", "no_option", "remote.way.too.long"],
)
def test_config_bad_name(name):
with pytest.raises(DvcParserError):
parse_args(["config", name])