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

New Horizons API #32

Merged
merged 9 commits into from
Jan 30, 2024
Merged

New Horizons API #32

merged 9 commits into from
Jan 30, 2024

Conversation

LuEdRaMo
Copy link
Collaborator

In order to address #31, this PR translates functions smb_spk, smb_spk_ele and vec_tbl to the new Horizons API.

@LuEdRaMo LuEdRaMo changed the title New Horizons API WIP: New Horizons API Jan 13, 2024
@LuEdRaMo
Copy link
Collaborator Author

LuEdRaMo commented Jan 13, 2024

@PerezHz what are your thoughts on this PR? Also, I have a couple of questions:

  1. Currently, I separate the original functions from the new ones via a ::Val{API} argument but, Is it worth keeping the telnet methods, since those require installing telnet externally while the new ones do not?
  2. Should I go ahead and implement other JPL APIs such as these?

@PerezHz
Copy link
Owner

PerezHz commented Jan 13, 2024

Hey @LuEdRaMo! Many thanks for this PR! I'll have a look to the details of this PR as soon as I can.

I would actually be in favor of scrapping the telnet methods (thus eliminating an external dependency in favor of a safer and more modern data-fetching API); ie I'm in favor of switching to the new HTTP API completely. Nostalgia-driven users won't mind using an older HORIZONS.jl version 🙃.

Regarding your second question, sure go ahead!

@PerezHz
Copy link
Owner

PerezHz commented Jan 13, 2024

Just a small caveat: we should add a warning to the users explaining that we switched APIs from telnet to HTTP.

@LuEdRaMo
Copy link
Collaborator Author

I have a few more comments/questions:

  1. Should we bump the major or the minor version?
  2. Except for horizons(), the other functions have been adapted to the new API.
  3. The only function that I have not adapted yet is vec_tbl_csv, is it worth keeping it? I feel that it could belong to a DataFrames extension.
  4. I still have to update README.md.
  5. I've written new tests.
  6. So far, I've implemented 3 of the JPL APIs (Horizons, SBDB and Radar Astrometry), I think the rest can be the subject of future PRs.

@PerezHz
Copy link
Owner

PerezHz commented Jan 29, 2024

Should we bump the major or the minor version?

Before 1, versions 0.x are considered breaking among themselves, so bumping the minor version should enough in this case.

Except for horizons(), the other functions have been adapted to the new API.

Okay, eventually the telnet method to connect to Horizons will be removed by JPL, but let's keep it for the time being.

The only function that I have not adapted yet is vec_tbl_csv, is it worth keeping it? I feel that it could belong to a DataFrames extension.

I agree that vec_tbl_csv is not essential and perhaps a bit redundant; feel free to deprecate it.

I still have to update README.md.

So far it has worked as the documentation of the package, so on this point I do think it's worth to update together with this PR.

I've written new tests.

Many thanks for adding those!

So far, I've implemented 3 of the JPL APIs (Horizons, SBDB and Radar Astrometry), I think the rest can be the subject of future PRs.

I think that's more than enough for what the package is already covering; I agree we can leave the rest of the JPL APIs for future PRs, I'd suggest to just open an issue here regarding that point.

@PerezHz
Copy link
Owner

PerezHz commented Jan 29, 2024

Btw, julia 1.0 tests are failing, can you update the CI.yml to test julia 1.6, 1 and nightly?

Project.toml Show resolved Hide resolved
@test isa(apophis_1["data"], Vector{Any})
@test isa(apophis_1["count"], String)
@test length(apophis_1["data"]) == parse(Int, apophis_1["count"])

Copy link
Owner

@PerezHz PerezHz Jan 30, 2024

Choose a reason for hiding this comment

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

I think around here we can add some tests to check the output, e.g.:

Suggested change
@test apophis_1["fields"] == ["des", "epoch", "value", "sigma", "units", "freq", "rcvr", "xmit", "bp", "observer"]
@test all(first.(apophis_1["data"]) .== "99942")
@test apophis_1["signature"]["source"] == "NASA/JPL Small-Body Radar Astrometry API"
@test VersionNumber(apophis_1["signature"]["version"]) v"1"

Copy link
Owner

Choose a reason for hiding this comment

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

(EDIT: added @test to suggestions above)

@test isa(apophis_2["data"], Vector{Any})
@test isa(apophis_2["count"], String)
@test length(apophis_2["data"]) == parse(Int, apophis_2["count"])

Copy link
Owner

Choose a reason for hiding this comment

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

@test apophis_2["fields"][end] == "observer"

@LuEdRaMo LuEdRaMo marked this pull request as ready for review January 30, 2024 14:56
@LuEdRaMo
Copy link
Collaborator Author

In the last commits I've addressed all your comments @PerezHz. I think this PR is ready for review.

Copy link
Owner

@PerezHz PerezHz left a comment

Choose a reason for hiding this comment

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

I think this is essentially ready for merging, there's just a couple of issues with the tests that we should address first, otherwise, LGTM! Many thanks again @LuEdRaMo!

test/runtests.jl Outdated
x = readlines(local_file)
y = split(apophisvt, "\n")[1:end-1]

@test x == y
Copy link
Owner

@PerezHz PerezHz Jan 30, 2024

Choose a reason for hiding this comment

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

Tests are failing in 1.6 and 1.10, I'd suggest to change this test to something like this:

Suggested change
@test x == y
@test length(x) == length(y)
lx = length(x)
inds = setdiff(1:lx,[2,35]) # avoid lines 2 and 35, since they have time of retrieval
@test x[inds] == y[inds]

Copy link
Owner

Choose a reason for hiding this comment

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

(edit: above I meant julia 1.6; wrote 1.9 instead)

@PerezHz
Copy link
Owner

PerezHz commented Jan 30, 2024

@LuEdRaMo Just left one last comment. Let me know when this is ready, and then we should be good to go!

@PerezHz
Copy link
Owner

PerezHz commented Jan 30, 2024

Deleted my last comment, the branching was swapped; will update my suggestion in a bit 😅

src/common.jl Outdated Show resolved Hide resolved
@PerezHz
Copy link
Owner

PerezHz commented Jan 30, 2024

I went ahead and committed the suggestion; if we get the green lights I'll merge, thanks a lot!

@LuEdRaMo
Copy link
Collaborator Author

LuEdRaMo commented Jan 30, 2024

I went ahead and committed the suggestion; if we get the green lights I'll merge, thanks a lot!

Thank you @PerezHz and sorry for the delay. On my side everything looks fine...

I'm excited about the applications of this PR in NEOs.

@PerezHz
Copy link
Owner

PerezHz commented Jan 30, 2024

Thank you @PerezHz and sorry for the delay. On my side everything looks fine...

No worries, and great catch on the breaking changes warning!

I'm excited about the applications of this PR in NEOs.

Indeed, me too! 😄

@PerezHz PerezHz merged commit 8f61817 into PerezHz:master Jan 30, 2024
6 checks passed
@PerezHz PerezHz mentioned this pull request Jan 30, 2024
@PerezHz PerezHz changed the title WIP: New Horizons API New Horizons API Jan 30, 2024
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