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

DOC: Integrate the content of the "/examples" directory into docs [Issue #396] #443

Merged
merged 11 commits into from
Jul 28, 2023

Conversation

chmmao
Copy link
Contributor

@chmmao chmmao commented May 9, 2023

Greetings,

This PR aims to address the issue #396.

I tried to integrate the examples shown in the examples directory into the docs for registry.
Not everything is integrated but I have chosen the most important ones in my opinion.
Hopefully it would resolve (partly) the issue, I am glad to hear improvements and potential mistakes.

@bsipocz
Copy link
Member

bsipocz commented May 10, 2023

Thank you so much, this is a great improvement. Could you please cull the examples/ content as part of this PR? Everything that you integrated over into the narrative docs, as well as anything that you find outdated or irrelevant.

@chmmao
Copy link
Contributor Author

chmmao commented May 17, 2023

Thank you so much, this is a great improvement. Could you please cull the examples/ content as part of this PR? Everything that you integrated over into the narrative docs, as well as anything that you find outdated or irrelevant.

Yes, you can see in the changed files.
Basically I have integrated these files:
'images/ex_casA_image_cat.py'
'images/ex_get_cutouts.py'
'notebooks/simple_service_discovery.ipynb'
'notebooks/working_with_registry_results.ipynb'

In each file I have written comments about what part I exactly integrated into the registry docs (lines are given), what I think are unnecessary. I would not delete them right now, once everyone reviewing this PR agree, I will delete the files. In my opinion, all these 4 files can thus be deleted.

For the 'auth/' folder I am not sure what to do with them, as well as for the 'serialquery.py'.

@andamian
Copy link
Contributor

@chmmao - thank you for picking this up!

I'm not sure what to do about the things in auth. While these examples should still work, auth is being revisited by the IVOA community and we might need to update it at some point. At the same time, a point was raised about service validators not being able to access authenticated services. If a solution is found, that might be applicable for the auth examples too but we are not there yet. I don't know what to do with them in the meantime. Move them to documentation without testing them? What do others think?

As for serialquery.py I think that can go unless @msdemlei disagree.

@@ -24,3 +24,7 @@
for image in results:
print("Downloading %s..." % name)
image.cachedataset(filename="NVSSimages/%s.fits" % name)

# This file can be deletd
Copy link
Member

Choose a reason for hiding this comment

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

Please do delete the file (and the other similar ones, especially the notebooks) instead of commenting in it. The ultimate aim is to get rid of the examples directory altogether.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok sure, they are deleted now.

@bsipocz
Copy link
Member

bsipocz commented May 18, 2023

Move them to documentation without testing them? What do others think?

If they are expected to work, then yes, move them to the documentation with turning off testing. Keeping the examples directory, with absolutely untested code, and out of sight, is IMO not very useful. Better to keep the content in docs, and if testing is skipped on it, at least it's easy to grep for (and/or receiving user comments on it).

@chmmao
Copy link
Contributor Author

chmmao commented May 24, 2023

Thanks for the review and for the suggestion you made:

Move them to documentation

I wonder which docs section should I move them to?

@bsipocz
Copy link
Member

bsipocz commented May 24, 2023

Practically you've already moved the content, I mean we should not keep notebook files anywhere in this repo.

Comment on lines 295 to 306
.. doctest-remote-data::

>>> import pyvo as vo
>>> from astropy.coordinates import SkyCoord

>>> import warnings
>>> warnings.filterwarnings('ignore', module="astropy.io.votable.*")

>>> archives = vo.regsearch(servicetype='image', waveband='x-ray')
>>> pos = SkyCoord.from_name('Cas A')
>>> len(archives) # doctest: +IGNORE_OUTPUT
33
Copy link
Member

Choose a reason for hiding this comment

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

For example, this example generates a CI test failure, as due to the empty lines it is picked up as 3 separate examples and remote-data only added for the first one.

I would suggest to add >>> in the empty lines as well, so eventually everything stays as one example.

Suggested change
.. doctest-remote-data::
>>> import pyvo as vo
>>> from astropy.coordinates import SkyCoord
>>> import warnings
>>> warnings.filterwarnings('ignore', module="astropy.io.votable.*")
>>> archives = vo.regsearch(servicetype='image', waveband='x-ray')
>>> pos = SkyCoord.from_name('Cas A')
>>> len(archives) # doctest: +IGNORE_OUTPUT
33
.. doctest-remote-data::
>>> import pyvo as vo
>>> from astropy.coordinates import SkyCoord
>>>
>>> import warnings
>>> warnings.filterwarnings('ignore', module="astropy.io.votable.*")
>>>
>>> archives = vo.regsearch(servicetype='image', waveband='x-ray')
>>> pos = SkyCoord.from_name('Cas A')
>>> len(archives) # doctest: +IGNORE_OUTPUT
33

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much! I was wondering why it did not work since the code seem to be fine and docktest runs pretty well locally. Now the issue is fixed.

@codecov
Copy link

codecov bot commented Jun 6, 2023

Codecov Report

Merging #443 (469c56a) into main (feda0f0) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #443   +/-   ##
=======================================
  Coverage   79.98%   79.98%           
=======================================
  Files          52       52           
  Lines        6036     6036           
=======================================
  Hits         4828     4828           
  Misses       1208     1208           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

Please squash the example changing commits out from the commits, and fix the servicetype table, or let me know if you want me to do it.
Otherwise all looks good. Thank you!


===== ======================================
sia Simple Image Access (SIA) services
ssa Simple Spectral Access (SSA) services
Copy link
Member

Choose a reason for hiding this comment

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

Even if the aliases are dismissed from this list, do add sia2 to this table.
or maybe, instead link to the class docs ( as ~pyvo.registry.Servicetype) that has the list (e.g. eliminate the need to maintain such a list at two places).


.. doctest-remote-data::

>>> for service in archives: # doctest: +ELLIPSIS
Copy link
Member

Choose a reason for hiding this comment

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

I suspect this should all work without the ELLIPSIS (as it should be opted in by default). If it's not, then it's an issue to be opened and followed-up.


.. doctest-remote-data::

>>> cats = vo.regsearch(keywords=['blazar','Fermi'])
Copy link
Member

Choose a reason for hiding this comment

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

Some style fixes are needed for the example, nothing serious, but adding and removing a few whitespaces here and there. I'm happy to do such fixes before merging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am very sorry for replying after such a long time, I have not been focusing on GitHub for a while. I have made changes such as:

  1. use the ~pyvo.registry.Servicetype link for the parameters
  2. some whitespaces fixes.
    For this one:

.. doctest-remote-data::

for service in archives: # doctest: +ELLIPSIS

I used ELLIPSIS because the output is a very long list of services, I just took the first three of them as examples. I don't think without ELLIPSIS it would pass the test.

And... I tried to rebase/squash all commits into one, and somehow the result does not look like what I wanted. But the overall changes are still there, I would appreciate if you could help me here. :)

Copy link
Member

Choose a reason for hiding this comment

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

Re ELLIPSIS:

it should work as we enable it by default. If it doesn't then something in our doctest config went wrong, so I'll double check it.

And... I tried to rebase/squash all commits into one, and somehow the result does not look like what I wanted. But the overall changes are still there, I would appreciate if you could help me here. :)

Yeap, will do that (and will post the commands I use here, so you can check which one you did differently). Thanks for trying, and thanks for the rest of the fixes.

Copy link
Member

Choose a reason for hiding this comment

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

Re rebase, here is the big picture and the copy paste of what I see in my local setup:

  1. locally you need the clone of astropy, and your fork, check it with git remote -v
  2. fetch to update the remotes
  3. rebase
  4. push back to your remote branch.
$ git remote -v
astropy	git@github.com:astropy/pyvo (fetch)
astropy	git@github.com:astropy/pyvo (push)
bsipocz	git@github.com:bsipocz/pyvo (fetch)
bsipocz	git@github.com:bsipocz/pyvo (push)
chmmao	git@github.com:chmmao/pyvo (fetch)
chmmao	git@github.com:chmmao/pyvo (push)
$ git fetch --all --prune
Fetching bsipocz
Fetching astropy
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), 660 bytes | 660.00 KiB/s, done.
From github.com:astropy/pyvo
   b96a950..feda0f0  main       -> astropy/main
Fetching chmmao
$ git rebase -i astropy/main
# editor comes up, do the commit reorders, squashes, removal of duplicates (if there is any from a previous rebase, etc). Note that we rebase on astropy/main and not on the main of your fork
# 
# When rebase is finished (you may need to do a bunch of git rebase --continue, etc., push it back. 
$ git push chmmao HEAD:integrate_examples --force
# note about the --force, it's needed as you overwrite the branch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you so much! Good to know how to do that properly.

@bsipocz bsipocz added this to the v1.5 milestone Jul 6, 2023
Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

Thank you @chmmao for this cleanup, I'm so glad to see the examples directory is gone and the content is now actually tested and exposed in the user documentation.

@bsipocz bsipocz merged commit 4bb146a into astropy:main Jul 28, 2023
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants