Skip to content
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

Rs/support rm progress #1664

Merged
merged 7 commits into from
Aug 13, 2020
Merged

Rs/support rm progress #1664

merged 7 commits into from
Aug 13, 2020

Conversation

romasku
Copy link
Contributor

@romasku romasku commented Aug 7, 2020

Closes #1663

@codecov
Copy link

codecov bot commented Aug 7, 2020

Codecov Report

Merging #1664 into master will increase coverage by 0.04%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1664      +/-   ##
==========================================
+ Coverage   76.78%   76.83%   +0.04%     
==========================================
  Files          59       59              
  Lines        8733     8763      +30     
  Branches     1424     1427       +3     
==========================================
+ Hits         6706     6733      +27     
- Misses       1829     1831       +2     
- Partials      198      199       +1     
Flag Coverage Δ
#unit 76.83% <88.88%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
neuromation/api/utils.py 98.79% <ø> (ø)
neuromation/cli/storage.py 31.57% <40.00%> (+0.01%) ⬆️
neuromation/api/storage.py 93.88% <92.30%> (-0.11%) ⬇️
neuromation/api/abc.py 100.00% <100.00%> (ø)
neuromation/cli/formatters/storage.py 90.73% <100.00%> (+0.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 045d759...c757842. Read the comment docs.

@romasku romasku force-pushed the rs/support-rm-progress branch 2 times, most recently from 6b12bde to 1f1b0f8 Compare August 7, 2020 12:04
@asvetlov
Copy link
Contributor

asvetlov commented Aug 7, 2020

Uhh, the PR is quite longer than I expected.

@romasku
Copy link
Contributor Author

romasku commented Aug 7, 2020

Uhh, the PR is quite longer than I expected.

Sorry for that. I tried to do work step by step in commits. If you want, I can close this PR and create smaller ones for different commits.

neuromation/api/storage.py Show resolved Hide resolved
@@ -735,67 +785,23 @@ def _file_status_from_api_stat(cluster_name: str, values: Dict[str, Any]) -> Fil
ProgressQueueItem = Optional[Tuple[Callable[[Any], None], Any]]


class QueuedProgress:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it was necessary to rewrite the code related to progress?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QueuedProgress was already little bit wrongly typed: it was used for both AbstractFileProgress and AbstractRecursiveFileProgress with casts like the following:

progress = cast(AbstractRecursiveFileProgress, self._progress)

Moreover, AbstractDeleteProgress is not subclass of AbstractFileProgress, so trying to reuse it would lead to even more strange typing. So I decided to generalize the pattern (put calls into asyncio.Queue) to make it easy to reuse it for my case and make for solid typing by adding _AsyncAbstract... classes. Initially I thought that I will be able to do proper annotations using generics, but I don't know any way to say mypy that function returns almost same type but all methods are replaced with coroutines.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I think that it would be better to split this PR on two parts. One implements the rm progress and other refactors the progress machinery.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR for refactoring the progress machinery: #1667
Sorry that I didn't do this initially.

@@ -127,3 +129,63 @@ def find_project_root(path: Optional[Path] = None) -> Path:
return here
here = here.parent
raise ConfigError(f"Project root is not found for {path}")


class QueuedCall:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use just partial()?

@asvetlov
Copy link
Contributor

asvetlov commented Aug 7, 2020

@romasku no, the PR size is acceptable.
I would just mention that careful review takes time.

@romasku romasku force-pushed the rs/support-rm-progress branch from 1f1b0f8 to 6ed9521 Compare August 12, 2020 14:54
@@ -0,0 +1 @@
Added `progress` argument to `Storage.rm` for tracking delete progress
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document also the CLI option. Most users use the CLI.

async with self._core.request("DELETE", url, auth=auth) as resp:
resp # resp.status == 204
def server_status_to_uri(path: str) -> URL:
base_uri = URL.build(scheme="storage", authority=self._config.cluster_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is constant and can be created outside of the loop.

Copy link
Contributor

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@romasku romasku merged commit 01ad1ba into master Aug 13, 2020
@romasku romasku deleted the rs/support-rm-progress branch August 13, 2020 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make use of streamed delete progress
3 participants