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

suggest some minor things to API #1032

Merged
merged 2 commits into from
Mar 4, 2020
Merged

suggest some minor things to API #1032

merged 2 commits into from
Mar 4, 2020

Conversation

shcheklein
Copy link
Member

You may disregard these recommendations if you used the Edit on GitHub button from dvc.org to improve a doc in place.

❗ Please read the guidelines in the Contributing to the Documentation list if you make any substantial changes to the documentation or JS engine.

🐛 Please make sure to mention Fix #issue (if applicable) in the description of the PR. This causes GitHub to close it automatically when the PR is merged.

Please chose to allow us to edit your branch when creating the PR.

Thank you for the contribution - we'll try to review it as soon as possible. 🙏

@shcheklein shcheklein temporarily deployed to dvc-landing-api-suggest-etva6c March 3, 2020 01:13 Inactive
Comment on lines -16 to +22
resource_url = dvc.api.get_url(
dvc.api.get_url(
'get-started/data.xml',
repo='https://github.com/iterative/dataset-registry')

# https://remote.dvc.org/dataset-registry/a3/04afb96060aad90176268345e10355
Copy link
Contributor

Choose a reason for hiding this comment

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

Agee about removing the var name but its not very obvious what the comment below is (and probably creates a horizontal scroll). Not sure it's needed for basic usage.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's intuitively clear ... we can even bring var name back in the comment ... we need to show something than nothing

we can just add

`# returns 'http://....'

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the basic usage block needs to show the variable value. That's what examples are for I think.

But if you want to keep this I would not reintroduce var name, maybe just make the comment shorter? # https://remote.dvc.org/dataset-registry/a3/04a... (maybe in the example BTW, so that no scrolls are shown) but not a huge deal about the scrolls for these cases.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it makes this example significantly better if we show the value, I would even say that this the most important part - you see right away what it does

I would keep at as simple as possible, would add returns at most

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. Actually I would reintroduce the var name now that I think about it. You wouldn't call a string returning function without assigning it to something. So my full suggestion is:

resource_url = dvc.api.get_url(
    'get-started/data.xml',
    repo='https://github.com/iterative/dataset-registry')
    
# resource_url = https://remote.dvc.org/dataset-registry/a3/04a...

Copy link
Contributor

@jorgeorpinel jorgeorpinel Mar 3, 2020

Choose a reason for hiding this comment

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

Or wrap in print() and say # prints http... in the comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

don't use = though, write it in a plain language - resource_url is now 'http:///'

Copy link
Member Author

Choose a reason for hiding this comment

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

otherwise it looks like a commented code

Comment on lines +38 to 45
If the target is a directory, the returned URL will point to a file that
contains the mapping of files in the directory (as a JSON array), along with
their hash values. Refer to
[Structure of cache directory](/doc/user-guide/dvc-files-and-directories#structure-of-cache-directory)
and `dvc add` to learn more about how DVC handles data directories.

⚠️ This function does not check for the actual existence of the file or
directory in the remote storage.

This comment was marked as resolved.

This comment was marked as resolved.

This comment was marked as resolved.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK to move it but the original text is a little better I think, because it doesn't imply that the .dir file will exist (and contain "the mapping of files...").

Copy link
Member Author

Choose a reason for hiding this comment

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

not sure I got the point ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I just wanted to avoid to many details (like .dir, etc - it's internal stuff)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think mentioning the .dir ending is appropriate as it may be something the user notices and wonders about when using this fn.

Suggested change
If the target is a directory, the returned URL will point to a file that
contains the mapping of files in the directory (as a JSON array), along with
their hash values. Refer to
[Structure of cache directory](/doc/user-guide/dvc-files-and-directories#structure-of-cache-directory)
and `dvc add` to learn more about how DVC handles data directories.
⚠️ This function does not check for the actual existence of the file or
directory in the remote storage.
If the target is a directory, the returned URL will end in `.dir`: a file that
contains the mapping of files in the directory. Refer to
[Structure of cache directory](/doc/user-guide/dvc-files-and-directories#structure-of-cache-directory)
and `dvc add` to learn more about how DVC handles data directories.
⚠️ This function does not check for the actual existence of the file or
directory in the remote storage.

Copy link
Member Author

Choose a reason for hiding this comment

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

they should not care about such specifics, we might change schema for those URL ... we can mention something like (ends with .dir) - but that should be enough

Copy link
Contributor

Choose a reason for hiding this comment

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

we can mention something like (ends with .dir) - but that should be enough

Good idea. Keeping the last sentence too (link to dvc dir struct), I assume.

Comment on lines -88 to 95
---
It prints
`https://remote.dvc.org/dataset-registry/a3/04afb96060aad90176268345e10355` if
we run it:

```dvc
$ python script.py
Copy link
Contributor

Choose a reason for hiding this comment

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

This is repetitive. Maybe just something like "Prints the URL string value if we run it from terminal:" ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Again, it's easier to read. Repetition not a big problem. Code snippet just illustrates the code (and gives a command to run). I would keep it extra explicit. Up yo you again. Don't have a strong opinion

Copy link
Contributor

@jorgeorpinel jorgeorpinel Mar 3, 2020

Choose a reason for hiding this comment

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

Repetition not a big problem.

Yeah but why do it if it's not needed? Just keeping the top paragraph and end it in "if we run it.", and removing the console block code should be enough I think.

p.s. The original one I did with the --- hr was also kind of obvious, like in the basic usage comment 🙂 and I like how it looked rendered.

This comment was marked as resolved.

This comment was marked as resolved.

@shcheklein shcheklein temporarily deployed to dvc-landing-api-suggest-etva6c March 3, 2020 01:58 Inactive
@jorgeorpinel
Copy link
Contributor

I'm going to merge this and address the remaining stuff in the api branch (#908 PR).

@jorgeorpinel jorgeorpinel merged commit fcbdefd into api Mar 4, 2020
@jorgeorpinel
Copy link
Contributor

Done! In 8089423.

@shcheklein shcheklein deleted the api-suggestions branch March 27, 2020 20:07
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.

2 participants