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

[Feature request] Offline use #1032

Open
tushev opened this issue Jan 8, 2025 · 1 comment
Open

[Feature request] Offline use #1032

tushev opened this issue Jan 8, 2025 · 1 comment

Comments

@tushev
Copy link

tushev commented Jan 8, 2025

I would like to use Skyfield in a code inside a Docker container. As a good security practice, it's better to limit resources that an app/container can access - and this includes Internet access (unless the code absolutely HAS to access the Internet).

Other situations I've seen here (a fully offline RPi etc) will also benefit from this capability. Plus it will help in case of outages of original data sources (for example, NAIF at JPL is unavailable at the moment of writing this).

What I would like to have:

  • a backup, fallback dataset that would be used if there's no internet connectivity. Probably shipped with Skyfield in a bundle, as a separate pip package, i.e. skyfield-offline. Same lib names, just a larger package for those who prefer it - similarly to how we have netinstall and quasi-'full' ISO for many Linux distros.
  • OR a comprehensive list of URLs that could be downloaded and preliminarily placed in data dir, and will cover 99% of use cases (except the ones that require fast-expiring data).
  • an offline mode for loader where it will not even try to reach the internet, and use existing data or fail immediately
  • docs on all this :)

Linking #89

@tushev
Copy link
Author

tushev commented Feb 7, 2025

For those who stumble upon this from search: this is how you can achieve this manually:

from skyfield.api import Loader, PlanetaryConstants

url_list = []
load = Loader('./skyfield_data')

eph_url = load.build_url('de421.bsp')
url_list.append(eph_url)
eph = load(eph_url)

# until https://github.com/skyfielders/python-skyfield/commit/d24c0ca2b8dad14bbad3ebfa921f7f5776a1a213 gets released
ts_url = 'https://datacenter.iers.org/products/eop/rapid/standard/finals2000A.all' 
url_list.append(ts_url)
load.open(ts_url, filename='finals2000A.all')
ts = load.timescale(builtin=False)

tf_url = load.build_url('moon_080317.tf')
url_list.append(tf_url)

# ... etc

# list all urls
for url in url_list:
    print(url)

Also, https://github.com/skyfielders/python-skyfield/tree/master/ci may help.

As a further suggestion for my original request: maybe add this functionality to https://rhodesmill.org/skyfield/api-iokit.html#skyfield.iokit.Loader ? i.e. a list_urls method that will output an array of all URLs collected automatically on every call of any load/download method. Maybe URL list collection should be triggered only with additional flag, i.e. Loader(collect_urls=True).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants