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

added new module and necessary refactorings #500

Merged
merged 7 commits into from
Sep 24, 2024

Conversation

Anu-Ra-g
Copy link
Contributor

@Anu-Ra-g Anu-Ra-g commented Sep 8, 2024

This PR adds a new module called _grib_idx.py with private functions and added necessary refactorings

@martindurant
Copy link
Member

How does this one relate to #499 ?

@@ -0,0 +1,250 @@
import ujson
Copy link
Member

Choose a reason for hiding this comment

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

Since this module does not have user functions (which should be exposed via kerchunk.grib), I think the whole module ought to have a docstring to explain this.

k_ind.loc[:, "idx"] = idx
return k_ind


def build_idx_grib_mapping(
Copy link
Member

Choose a reason for hiding this comment

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

Why did this function not move? I would think it should live in _grib_index, but it can be imported here, to indicate that, yes, it is user-facing.

Copy link
Member

@martindurant martindurant left a comment

Choose a reason for hiding this comment

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

parse_grib_idx and other functions are definitely part of the idx workflow only, I expected they would be moved.

@Anu-Ra-g
Copy link
Contributor Author

@martindurant I've made the changes as you asked. But the pre-commit is failing on the unused imports when I made the function as user facing in kerchunk.grib2 module.

@martindurant
Copy link
Member

the pre-commit is failing on the unused imports

You can fix this by including an __all__, which should be a list of strings to be considered as "public" in the module. Making this list has two effects:

  • making the imports look like they are used
  • defining what gets imported if you were to do from kerchunk.grib import *.

@Anu-Ra-g
Copy link
Contributor Author

Should I add the original functions like scan_grib, grib_tree etc to the list or only the indexing functions?
__all__ = ["build_idx_grib_mapping", "map_from_index"]

@martindurant
Copy link
Member

Yes please, add all the public functions, just incase some one does do a "*" import.

@Anu-Ra-g
Copy link
Contributor Author

@martindurant made the changes

@martindurant martindurant merged commit f9df05d into fsspec:main Sep 24, 2024
5 checks passed
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