ioos / erddapy

Python interface for ERDDAP
https://ioos.github.io/erddapy/
BSD 3-Clause "New" or "Revised" License
77 stars 30 forks source link

Add public methods to erddapy module #281

Closed vinisalazar closed 1 year ago

vinisalazar commented 1 year ago

Hi,

while working on the docs for the core interface, I realised that the URL parsing and interfaces methods would have to be directly imported from their respective modules, rather than being accessed from the erddapy module. This seemed a bit unintuitive, so I added public methods directly to the erddapy.__init__ module.

Users can then run:

from erddapy import get_download_url, to_pandas

url = get_download_url(...)
df = to_pandas(url)

# or
import erddapy

url = erddapy.get_download_url(...)
df = erddapy.to_pandas(url)

instead of

from erddapy.core.url import get_download_url
from erddapy.core.interfaces import to_pandas

which seems much harder to do.

Summary of changes:

abkfenris commented 1 year ago

If we are going to expose them all at one spot, I'd rather expose them at erddapy.core rather than at the top level.

I think it would help clarify to users that refactoring is going on, and allow them to make an explicit choice which world to live in. It also would decrease the amount that is in a single namespace.

import erddapy.core

url = erddapy.core.get_download_url(...)
ocefpaf commented 1 year ago

Yep. I agreed with @abkfenris, putting them all at the root level would be a bit confusing for folks browsing the module. Having them into a .core is probably the best place for them.

vinisalazar commented 1 year ago

Done with https://github.com/ioos/erddapy/pull/281/commits/6fdb280abfc8dccce9f1f1c043723add642b33e6.

Users can run:

import erddapy

erddapy.core.get_download_url()
erddapy.servers
...

i.e. no need to import erddapy.core.