-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix ignored job count #7373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
fix ignored job count #7373
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,16 +7,19 @@ | |
|
|
||
| import dvc as dvc_module | ||
| from dvc.cli import main | ||
| from dvc.data.db.local import LocalObjectDB | ||
| from dvc.external_repo import clean_repos | ||
| from dvc.objects.db import ObjectDB | ||
| from dvc.stage.exceptions import StageNotFound | ||
| from dvc.testing.test_remote import ( # noqa, pylint: disable=unused-import | ||
| TestRemote, | ||
| ) | ||
| from dvc.utils.fs import remove | ||
|
|
||
|
|
||
| def test_cloud_cli(tmp_dir, dvc, remote): | ||
| args = ["-v", "-j", "2"] | ||
| def test_cloud_cli(tmp_dir, dvc, remote, mocker): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is getting crazier and crazier :) We'll get rid of it when we have lower level testing in dvc-data/objects. |
||
| jobs = 2 | ||
| args = ["-v", "-j", str(jobs)] | ||
|
|
||
| (stage,) = tmp_dir.dvc_gen("foo", "foo") | ||
| cache = stage.outs[0].cache_path | ||
|
|
@@ -34,25 +37,44 @@ def test_cloud_cli(tmp_dir, dvc, remote): | |
| cache_dir = stage_dir.outs[0].cache_path | ||
|
|
||
| # FIXME check status output | ||
| hashes_exist = mocker.spy(LocalObjectDB, "hashes_exist") | ||
|
|
||
| assert main(["push"] + args) == 0 | ||
| assert os.path.exists(cache) | ||
| assert os.path.isfile(cache) | ||
| assert os.path.isfile(cache_dir) | ||
| assert hashes_exist.called | ||
| assert all( | ||
| _kwargs["jobs"] == jobs | ||
| for (_args, _kwargs) in hashes_exist.call_args_list | ||
| ) | ||
|
|
||
| remove(dvc.odb.local.cache_dir) | ||
| hashes_exist.reset_mock() | ||
|
|
||
| assert main(["fetch"] + args) == 0 | ||
| assert os.path.exists(cache) | ||
| assert os.path.isfile(cache) | ||
| assert os.path.isfile(cache_dir) | ||
| assert hashes_exist.called | ||
| assert all( | ||
| _kwargs["jobs"] == jobs | ||
| for (_args, _kwargs) in hashes_exist.call_args_list | ||
| ) | ||
|
|
||
| hashes_exist.reset_mock() | ||
|
|
||
| assert main(["pull"] + args) == 0 | ||
| assert os.path.exists(cache) | ||
| assert os.path.isfile(cache) | ||
| assert os.path.isfile(cache_dir) | ||
| assert os.path.isfile("foo") | ||
| assert os.path.isdir("data_dir") | ||
| assert hashes_exist.called | ||
| assert all( | ||
| _kwargs["jobs"] == jobs | ||
| for (_args, _kwargs) in hashes_exist.call_args_list | ||
| ) | ||
|
|
||
| with open(cache, encoding="utf-8") as fd: | ||
| assert fd.read() == "foo" | ||
|
|
@@ -62,18 +84,38 @@ def test_cloud_cli(tmp_dir, dvc, remote): | |
| if remote.url.startswith("http"): | ||
| return | ||
|
|
||
| hashes_exist.reset_mock() | ||
|
|
||
| _list_hashes_traverse = mocker.spy(ObjectDB, "_list_hashes_traverse") | ||
| # NOTE: check if remote gc works correctly on directories | ||
| assert main(["gc", "-cw", "-f"] + args) == 0 | ||
| assert _list_hashes_traverse.called | ||
| assert all( | ||
| _kwargs["jobs"] == 2 | ||
| for (_args, _kwargs) in hashes_exist.call_args_list | ||
| ) | ||
| shutil.move(dvc.odb.local.cache_dir, dvc.odb.local.cache_dir + ".back") | ||
|
|
||
| assert main(["fetch"] + args) == 0 | ||
|
|
||
| assert hashes_exist.called | ||
| assert all( | ||
| _kwargs["jobs"] == jobs | ||
| for (_args, _kwargs) in hashes_exist.call_args_list | ||
| ) | ||
|
|
||
| hashes_exist.reset_mock() | ||
| assert main(["pull", "-f"] + args) == 0 | ||
| assert os.path.exists(cache) | ||
| assert os.path.isfile(cache) | ||
| assert os.path.isfile(cache_dir) | ||
| assert os.path.isfile("foo") | ||
| assert os.path.isdir("data_dir") | ||
| assert hashes_exist.called | ||
| assert all( | ||
| _kwargs["jobs"] == jobs | ||
| for (_args, _kwargs) in hashes_exist.call_args_list | ||
| ) | ||
|
|
||
|
|
||
| def test_data_cloud_error_cli(dvc): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like we were ignoring job count in
gctooUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have an issue for that: #5961.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this P.R. close #5961 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm looking into how easy it would be to add basic multithreading to
gc. For now, it only uses multithreading when listing objects from the odb (odb.all()) using_list_hashes_traverse.I think it should #5961 should be closed in another PR.