Commit Graph
100 Commits
Author SHA1 Message Date
Saugat Pachhai 0206812d1b Fix test assertion with environment when using pyenv (#5765) 2021-04-05 22:56:05 +05:45
Saugat PachhaiandSaugat Pachhai 19d0b2af56 use sys.executable instead of hardcoded python (#5763)
Co-authored-by: Saugat Pachhai (सौगात) <[email protected]>
2021-04-03 07:22:07 +00:00
Saugat Pachhai 7b25a9de24 Update pycryptodome to 3.10 (#5762)
3.10 has wheels for Python3.9 in Windows.
2021-04-03 12:10:24 +05:45
Saugat Pachhai 7c7e73e3d2 status: collect stages only once (#5741)
This is achieved by using `lock_repo`
context manager that can be used in a recursive depth
that only resets stages when it has left any lock_repo
blocks.

Also added some ui related tests for the status which I found
missing
2021-03-31 18:31:27 +03:00
Saugat Pachhai 098a519305 webdav: use root url to check and on mkdir to find recurse depth (#5742) 2021-03-31 15:46:49 +03:00
Saugat Pachhai 3b3b5c8997 parsing: resolve relative paths when loading parameters (#5734)
* parsing: resolve relative paths when loading parameters

* test with git commits as well
2021-03-30 23:50:04 +03:00
Saugat Pachhai b5f31daab0 ui: Use sys.stdout and sys.stderr dynamically (#5729)
Before, we used to set it during initialization. But this
made it hard to test using capsys as capsys changes the
reference to sys.stdout and sys.stderr with the mocked one
during the test. But since we are using dvc.ui globally and
setting it to a real sys.stdout and sys.stderr before capsys
comes into effect, testing was not possible with it.

Now, by using property hack, we will be using the values of
sys.stdout and sys.stderr during the time of write, so the mocking
would work and would be easier to test.
2021-03-30 23:44:46 +03:00
Saugat Pachhai 547db15d34 Add test_requirements.txt to the manifest (#5724) 2021-03-29 12:56:02 +05:45
Saugat Pachhai f6b04c54e0 deps: limit rich version to <10 (#5723)
The recent release of rich 10.0.0 broke some internal APIs
that we were depending on for exp show.
See https://github.com/iterative/dvc/issues/5722
2021-03-29 12:09:02 +05:45
Saugat Pachhai 0a2e9f98d5 dvc: update precommit hooks (#5716)
* update pre-commit hooks

* fix mypy errors

1. Casting `columns` to the custom Column with collapse.
2. Ignoring typedef difference for RichTable._collapse_widths.
3. Suppressing error with conditional paramiko imports
   https://github.com/python/mypy/issues/1153
2021-03-26 22:41:56 +05:45
Saugat Pachhai f8c56742c5 pin urllib3 to 1.26.4 (#5714) 2021-03-26 21:29:08 +05:45
Saugat Pachhai cd9098211f remove pytest-tap (#5713) 2021-03-26 20:43:57 +05:45
Saugat Pachhai 8c90771388 Add dependabot to update github-actions and python requirements (#5697) 2021-03-26 18:20:10 +05:45
Saugat Pachhai 1931a6ec1e Move tests requirements to test_requirements.txt (#5674)
Plan is to add dependabot to update those packages required for testing
2021-03-26 14:13:43 +02:00
Saugat Pachhai 76ece8c64a plots: quote and resolve paths properly (#5670)
This commit fixes 3 things:
1. The path printed on the terminal is properly is quoted.  This was
problematic when the output is piped to `xdg-open` if the path contained
spaces or quotes or special characters.

2. The path is resolved. This is not an issue at all, but makes the
output nicer.

3. The path with which the browser is opened with uses relative path.
This is done to solve issue in WSL, that the absolute path is not
accessible outside the WSL for host programs as the linux filesystem
is available on `/wsl$` path.
2021-03-24 20:27:24 +05:45
Saugat Pachhai 8b6d655ebe use global UI object for printing (#5653) 2021-03-24 17:22:17 +05:45
Saugat Pachhai dc3fe6fbec Update pylint-pytest to 1.0.3 (#5673) 2021-03-23 15:28:33 +05:45
Saugat Pachhai 0a8927e3d8 diff: clear calculated renamed files from inverted hashmap (#5652)
* diff: clear calculated renamed files from inverted hashmap

We were trying to reuse the first encounter of file from inverted hashmap again and again, which was throwing ValueError

* refactor

* remove ordering

* add tests
2021-03-22 15:13:52 +02:00
Saugat Pachhai f2b216261e move Repo.diff related test to diff (#5654) 2021-03-19 16:58:21 +05:45
Saugat Pachhai 0b810fb256 Advertise Python 3.9 support in classifiers 2021-03-16 13:37:37 +05:45
Saugat Pachhai d245008987 plots: support opening plots file directly in the browser (#5584)
* plots: support opening plots file directly in the browser

* add tests

* fix path on windows tests
2021-03-12 04:23:07 +02:00
Saugat Pachhai b691b15007 Add a link to help debugging more information regarding the issue (#5601)
* Add a link to help debugging more information regarding the issue

* Update .github/ISSUE_TEMPLATE/bug_report.md
2021-03-11 16:02:53 +02:00
Saugat Pachhai fd66ef6bc1 http: fix info() if there is no content-length header (#5602) 2021-03-11 16:01:24 +02:00
Saugat Pachhai e709437cd2 update pylint and pin dependencies (#5603)
Started having some issues with pylint-pytest, pinning it as well
2021-03-11 15:24:27 +05:45
Saugat Pachhai 6c00fedb46 remove flaky-service
Looks like the project is dead: https://github.com/GoogleCloudPlatform/flaky-service.

And, the site https://flaky.dev seems to be dead.
2021-03-11 15:21:12 +05:45
Saugat PachhaiandDave Berenbaum cccead3441 stage:list: update output and help text (#5499)
* stage:list: update output and help text

* Replaced 'Produces' with 'Outputs'
* Replaced 'Stage depends on' with just 'Depends on'
* Changes help text of --names-only and --fail

* Update dvc/command/stage.py

Co-authored-by: Dave Berenbaum <[email protected]>

* s/Generates/Reports

Co-authored-by: Dave Berenbaum <[email protected]>
2021-02-20 13:21:39 +05:45
Saugat Pachhai 14944dd9e0 Minor refactoring stage:list command (#5498)
Moving text truncation to utils and adding tests for it
2021-02-19 18:27:37 +05:45
Saugat Pachhai 45477a2a81 dvc.lock: raise error if the file is gitignored (#5484) 2021-02-18 03:08:00 +02:00
Saugat Pachhai d28f5675b4 remove support for double braces (#5476) 2021-02-16 17:21:47 +02:00
Saugat Pachhai ac9819eb02 introduce dvc.io module to consolidate io utilities (#5348)
* add dvc.ui module

The name of class has been changed to `Console` as the short form
name is too bad.

* add demo
2021-02-11 20:42:08 +02:00
Saugat Pachhai 02a0d1af52 stage: implement add/create methods in stage loader (#5397)
* stage: add/create methods in stage loader

* minor fixups
2021-02-08 18:30:10 +05:45
Saugat Pachhai 21200c14df refactor webdav to use client; extract write_text to base (#5411) 2021-02-04 16:48:25 +05:45
Saugat Pachhai b2c2929869 pyarrow support for Python3.9 (#5391) 2021-02-02 17:31:11 +02:00
Saugat Pachhai 67980de44d tests: mock global config dir for Updater (#5386) 2021-02-02 17:08:09 +05:45
Saugat Pachhai 4348832b44 keep stage.dump and dvcfile.dump in sync (#5382) 2021-02-02 15:11:13 +05:45
Saugat Pachhai b020918f5d stage:add: use remainder as a command script (#5350)
* stage:add use remainder as a command

* use -c for checkpoints

* use -n for stage name, make it required, fix tests
2021-02-01 17:50:04 +02:00
Saugat Pachhai 131eb7b3a1 don't allow loading stages without cmd (#5373)
* don't allow loading stages without `cmd`

This was loosened when introducing parametrization.
But, `foreach`..`do` should be considered first
before stage's regular structure. And, cmd is made
required (as it should have been)

Related: #5371, #5370, #5312

* fix schema
2021-02-01 13:23:40 +05:45
Saugat Pachhai b1d6918c5a stage collection: do not collect .gitignored dvcfiles (#5265)
* Do not collect .gitignored dvcfiles

* fix exc

* consistent error message

* fix imports

* add tests
2021-01-26 14:51:02 +02:00
Saugat Pachhai 9f0b86f221 unit.scm.test_git: use pytest instead of unittest (#5325) 2021-01-25 10:23:46 +05:45
Saugat Pachhai 3741f730e0 show git-add hint on stage:add, refactor scm_context (#5290)
* Refactor scm_context, show git-add hint on stage:add

* move tests
2021-01-24 22:43:38 +02:00
Saugat Pachhai 1d8761e0c9 Remove empty file tests/unit/command/test_commit.py (#5316)
When I opened it, I got confused for a second and had to double-check if it was really empty.
The empty file gives a false assurance. We do need to add one, which I'll add later, but for now,
we better remove it.
2021-01-23 18:27:43 +05:45
Saugat Pachhai 689ae22fb4 Fix code-style issues in the parsing module (#5299) 2021-01-20 17:21:57 +05:45
Saugat Pachhai d8982c6db7 Override __str__ implementation for StageNotFound (#5289)
This happens because KeyError quotes the error message.
We'd still like to keep StageNotFound being a KeyError
semantics, but workaround the __str__ implementation.

Mypy was having some problem with the previous `__str__`
override.
2021-01-19 18:33:18 +05:45
Saugat Pachhai 372d6f045b Introduce stage:list command with autocompletions (#5282)
* Implement stage:list

* change targets help message
2021-01-19 17:35:55 +05:45
Saugat Pachhai 55df6b8a6a cli: remove: Show traceback on verbose (#5287) 2021-01-19 15:10:56 +05:45
Saugat Pachhai 78e12327bc use repo.stage.create_from_cli to create stages (#5281) 2021-01-18 18:55:19 +05:45
Saugat Pachhai 628f87845c introduce stage:add command (#5263)
* Implement stage:add

* fix tests

* Add short flag -C for checkpoints
2021-01-18 10:05:36 +02:00
Saugat Pachhai 257f58450a refactor run; move to stage.utils (#5262)
* refactor run; move to stage.utils

* Update dvc/repo/run.py

* fix pylint

* skip on run-cache
2021-01-13 21:19:36 +02:00
Saugat Pachhai f8200ca2b8 move parsing params to utils (#5259)
* move parsing params to utils

* fix tests

* move chunk_dict and test it

* update test
2021-01-13 13:36:49 +02:00
Saugat Pachhai 49974c075c dvc: bump to 2.0.0a0 (#5250)
Looking at the log is confusing, as the version is stuck in `1.11.0` whereas the recent one is `1.11.10`.

As the updater is also dependent on that version, it prints an ugly update message while running too.
https://github.com/iterative/dvc/issues/5023#issuecomment-758450519
2021-01-12 09:24:57 +02:00
Saugat Pachhai a2c91d2058 scm: implement gitignore (#5243)
* scm: implement gitignore; use `pygit2` backend

* Add is_ignored implementation on `pygit2` and `gitpython` backends.
* Also implement `._reset()` on `repo.scm` which is most of the changes.

* fix tests

* use _backend_func

* minor fixups
2021-01-11 12:31:26 +02:00
Saugat Pachhai 388eccad13 fix mypy errors; add mypy precommit hooks (#5237) 2021-01-08 16:05:52 +02:00
Saugat Pachhai ccc17917cf Make few imports lazy on dvc.main (#5233)
* Moved exception handling imports wherever they occur
* Move dvc.tree and dvc.external_repo imports to it's
  nearest use, as it is expensive for `--version`.
* Move analytics import to when it's used
* Move format_link to place where error occurs
2021-01-07 15:55:34 +02:00
Saugat Pachhai c04cdaf70f Split config and schema (#5229)
so as not to compile a schema unless needed
2021-01-07 13:47:14 +02:00
Saugat Pachhai 9331ad23e4 Misc. imports lazy on utils,stage.cache and dvc.* (#5228) 2021-01-07 15:03:34 +05:45
Saugat Pachhai 66fc988ebf Make imports on dvc.repo and dvc.repo.plots lazy (#5227) 2021-01-07 15:02:31 +05:45
Saugat Pachhai 40122cefa5 parsing: make imports lazy (#5225)
* parsing: make imports lazy

* Locally declare default params file
2021-01-07 15:00:54 +05:45
Saugat Pachhai a9ccf70439 cmd: imports lazy (#5226)
They are not a major pain point though
2021-01-07 11:45:58 +05:45
Saugat Pachhai a9d620beda utils.serialize: lazy imports (#5224) 2021-01-07 11:44:37 +05:45
Saugat Pachhai af2a12a188 Use 'schema' top-level element in the lockfile for version (#5222) 2021-01-06 20:08:14 +02:00
Saugat Pachhai 0db41b94fc parametrization: do not load parser on import (#5217)
A great benefit to this is that, if the dvc.yaml file
is never interpolated, the parser is never built, which
reduces the gap even further between 1.0 and 2.0 files
2021-01-06 21:40:19 +05:45
Saugat Pachhai 2646c0d6bc Make some imports lazy for plots (#5219) 2021-01-06 17:41:30 +02:00
Saugat Pachhai 1cc646614f Misc. imports made lazy: scm,experiments,stage (#5218) 2021-01-06 17:41:12 +02:00
Saugat Pachhai 84e9c1b0de lazy imports on repo command (#5221) 2021-01-06 17:41:01 +02:00
Saugat Pachhai 4f692b0b69 Make repotree lazy (#5220)
Also removed dvcfile related imports on dvc.tree.repo.
This was making imports slower on dvc.main
2021-01-06 17:40:31 +02:00
Saugat Pachhai 9b73a745b4 Misc imports lazy (#5215) 2021-01-06 17:50:24 +05:45
Saugat Pachhai 4c53e636bc Move misc. imports from command, make them lazy (#5214) 2021-01-06 17:44:02 +05:45
Saugat Pachhai 40bd838c11 config command: lazily import (#5211) 2021-01-06 16:03:06 +05:45
Saugat Pachhai 709e121b31 package: Increment shtab's version (#5212) 2021-01-06 15:48:33 +05:45
Saugat Pachhai 0cc5227f47 Add versioning scheme in the dvc.lock (#5128)
* Add versioning scheme in the dvc.lock

* remove whitespace

* use actual size in tests assumptions
2021-01-06 15:44:19 +05:45
Saugat Pachhai 4f89db8e0d analytics: lazily import (#5210) 2021-01-06 15:32:27 +05:45
Saugat Pachhai c0fbdb3531 Lazily load git backends (#5203) 2021-01-05 09:46:24 +02:00
Saugat Pachhai c4970a016f debug functions: have a good default value (#5202)
I had to keep providing default value before when profiling
simple functions as an API. I added a default now, and
also made `debugtools` customizable so that you could
edit the code to, for example, have `pdb` enabled by default.
2021-01-04 20:16:42 +05:45
Saugat Pachhai 8010005364 Reraise exception after pdb.post_mortem() (#5197)
Otherwise, `continue` etc. would fail
2021-01-04 15:34:04 +05:45
Saugat Pachhai 261ddc947b Add pyinstrument: a statistical profiler (#5196)
* Add pyinstrument: a statistical profiler

It is easier than cprofile, in that it can show stacktrace
of where things are slow.

Also refactored/moved debugging related utils to a separate
module

* use ipdb first, then fallback to pdb

* use ipdb first, then fallback to pdb
2021-01-04 15:23:40 +05:45
Saugat Pachhai 01a4473c20 parametrization: fix error when the file in vars is a directory (#5171)
* Fix error when the file in `vars` is a directory

* Fix on windows

* mock tree only
2020-12-28 23:03:09 +02:00
Saugat Pachhai 77ff24260e Remove Sourcerer's hall of fame (#5168)
Sourcerer is gone: https://github.com/sourcerer-io/sourcerer-app/issues/632
2020-12-28 16:42:05 +02:00
Saugat Pachhai 4b30b8bea6 parametrization: move comment, fix exception error msg (#5142) 2020-12-21 13:04:55 +05:45
Saugat Pachhai 7e2520c02a Cleanup debug log messages when loading stages (#5125)
* Cleanup log messages when loading stages

1. Simplified callback stage debug message
2. Reduced no lock entry message to trace
   If lockfile does not have some entry, it will simply complain
   that lockfile is not uptodate once.
   If there is no lockfile or empty lockfile, it will complain that
   lockfile not found.
3. Annoying parametrization related wdir-interpolated debug message
   removed.

* Update dvc/stage/__init__.py

* black
2020-12-18 10:38:24 +02:00
Saugat Pachhai 723477ed5a Load from only two revisions in params/metrics (#5121) 2020-12-18 10:33:10 +02:00
Saugat Pachhai 76c6c54278 Fix backport branch 2020-12-18 12:02:13 +05:45
Saugat Pachhai dcce3a31a9 params diff: skip params dependency for vars (#5123)
* Skip paramdependency for vars

Previously, `configs` which was a list of PathInfo was being used
to check if the `vars` should be skipped or not.

But, the file is stored as a string that made that check redundant
which might have caused #5117 as they were being stored twice,
once as a expanded paramdependency and next as a flattened dict
from vars, which later during `flatten`, it might have panicked
from that duplication.

* Use defaultdict

* change add_vars to collect_vars
2020-12-18 12:00:06 +05:45
Saugat Pachhai 2512df7ca1 Prevent loading non-dict vars (#5107) 2020-12-15 19:21:31 +05:45
Saugat Pachhai 11c94b10f2 disallow overriding item and key in the foreach loop (#5104)
* Allow reserving keys in the context to prevent overriding

* Use nullcontext from funcy (3.6 Python)

* Display path in error message
2020-12-15 19:06:39 +05:45
Saugat Pachhai 6cad3c95dd Remove key/value magic strings (#5106) 2020-12-15 19:06:23 +05:45
Saugat Pachhai aa4ec8acd5 Skip building graph for dependencies without path_info (#5103)
RepoDependency for example don't have any path_info

See: https://github.com/iterative/dvc/pull/4938#issuecomment-743709176
Related: #5035
2020-12-15 16:34:39 +05:45
Saugat Pachhai 620d082b0b refactor resolver and optimize (#5077)
minor refactors, code comments

Rename interim to definitions

provide location of entry during init for definition

small fixups to set_temporarily

Refactor loop to use dict comprehension

Provide same interface for definitions

Make it work for composite lists

Check for sequence rather than a list

refactor tests

Fixes #4955
Fixes #4957
Fixes #4963
2020-12-14 19:22:15 +05:45
Saugat Pachhai 189e88f1db Run graph checks on collect/find_outs_by_path (#5035)
We try to optimize `tree.exists` calls and probably few others
in that they either look directly into the workspace or,
to the cache without running graph checks. It does not seem
to be possible just to run graph checks on `find_outs_by_path`
due to those optimizations.

So, that's why, the `collect` also does a graph check for this
reason.

Fixes #5027
Fixes #4010
2020-12-10 12:20:45 +02:00
Saugat Pachhai a7d665157c parametrization: disable set keyword (#5063) 2020-12-09 14:26:47 +05:45
Saugat Pachhai 995287bbba Pin numpy for windows build (#5055) 2020-12-08 18:07:14 +02:00
Saugat Pachhai 529073967e run/repro: show command on dry-run, add ">" to script output (#5041)
* run/repro: show command on dry-run, add ">" to script output

This rollbacks the earlier commit to not show command during
the dry-run, and also prepends ">" in the command script
instead of "$" sign.

* fix tests
2020-12-07 13:16:15 +02:00
Saugat Pachhai f49feddb7f provide a callback to handle error during the stage collection (#5020)
also provide a callable to properly handle error messages
add tests
2020-12-03 19:05:56 +05:45
Saugat Pachhai bb84f5d9e2 Enable parametrization by default (#5018)
* Enable parametrization by default

* Remove a way to disable parametrization

* Add a comment for the feature flag
2020-12-03 10:20:29 +02:00
Saugat Pachhai 3a3fa7cdde parametrization: convert bool to string as "true"/"false" (#5004)
Previously, Python's `str()` was being used that
resulted in boolean transformed into "True"/"False".

Fixes #4996
2020-12-01 16:05:18 +05:45
Saugat Pachhai 1e1a0999f6 parametrization: show interpolated vars in params diff (#5002)
* parametrization: show interpolated vars in params diff

* Add test for params.diff

* disable logging duration if feature is not enabled
2020-12-01 15:43:37 +05:45
Saugat Pachhai bc1d10532a Move Repo.collect and collect_granular to Repo.stage (#4993) 2020-11-30 14:28:16 +05:45
Saugat Pachhai f4f0554884 repro: support glob/foreach-group to run at once through CLI (#4976)
* repro: support regex/foreach-group to run at once

Fixes #4912
Fixes #4886
Fixes #4958

* Use `tree.isdir` rather than `os.path.isdir`

* Use glob rather than regex

* Update dvc/command/repro.py

* s/regex/glob

* disable glob on `collect_granular`

There's no need for a glob here

* add tests for `collect` and `collect_granular`
2020-11-27 19:13:38 +05:45
Saugat Pachhai 011bd18e9f parametrization: support loading vars partially (#4982) 2020-11-27 19:05:02 +05:45
Saugat Pachhai 6d745eb4f0 s3: use mocked s3 instead of the real one (#4968)
* s3: use mocked s3 instead of the real one

Not removing the fixtures just yet

* Update moto

Tests was failing, because of a change in `responses` package, which
`moto` was mocking. This was fixed on
https://github.com/spulec/moto/pull/3466 which is only available on
`dev122` release.

* Use mocked s3 in checkout tests
2020-11-26 11:30:43 +05:45
Saugat Pachhai 788d840e7d tests/ci: update docker image for Azurite (#4967)
`Azure` tests are flaky for some reason. When I investigated one
of the job [1], something seemed wrong with the Azurite or
the client lib.

On `AzureTree.blob_service`, we do the following to check if the
container exists:
```python
try:
    container_client.get_container_properties()
except ResourceNotFoundError:
    container_client.create_container()
```

When looking at the test log, I found out that the
`get_container_properties` was failing with
`ErrorCode:ContainerNotFound` whereas `create_container`
successively was failing with `ErrorCode:ContainerAlreadyExists`.

`create_container` is correct, but `get_container_properties` is
incorrect, as many of the Azure tests have already run successfully
before.

So, either the Azurite has/had bug or the client lib has a bug.
Anyway, we'll find out after updating the Azurite.

[1]: https://github.com/iterative/dvc/runs/1448864706#step:7:4029
2020-11-25 21:21:00 +02:00