Skip to content

added new module and necessary refactorings#500

Merged
martindurant merged 7 commits intofsspec:mainfrom
Anu-Ra-g:refactor
Sep 24, 2024
Merged

added new module and necessary refactorings#500
martindurant merged 7 commits intofsspec:mainfrom
Anu-Ra-g:refactor

Conversation

@Anu-Ra-g
Copy link
Copy Markdown
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
Copy Markdown
Member

How does this one relate to #499 ?

Comment thread kerchunk/_grib_idx.py
@@ -0,0 +1,250 @@
import ujson
Copy link
Copy Markdown
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.

Comment thread kerchunk/grib2.py Outdated
return k_ind


def build_idx_grib_mapping(
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

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

@Anu-Ra-g
Copy link
Copy Markdown
Contributor Author

@martindurant made the changes

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