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

Disallowing confusing None from IndexSettings.index_directory, and IndexSettings.get_named_index_directory #531

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

jamesbraza
Copy link
Collaborator

The None from IndexSettings.index_directory was a failover to the default IndexSettings.index_directory inside of SearchIndex. This has two issues:

  • That failover "desynchronizes" IndexSettings from SearchIndex, which tripped me up
  • I think None for index_directory could imply "no index dir" as opposed to "default index dir"

Also, I implemented a convenience utility IndexSettings.get_named_index_directory, with a test

@jamesbraza jamesbraza added the enhancement New feature or request label Oct 4, 2024
@jamesbraza jamesbraza self-assigned this Oct 4, 2024
@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 4, 2024
"Getting a named index directory requires an index name to have been"
" specified, please specify a name."
)
return anyio.Path(self.index_directory) / self.name
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this a anyio.Path and index_directory is os.PathLike? Are those types compatible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah good question, it comes down to "be vague in what you accept, and specific in what you return"

index_directory is an input that allows general types of str | os.PathLike:

  • str is for places like configs
  • os.PathLike is basically an ABC for pathlib.Path-like objects

The return is a concretion of os.PathLike, which is an anyio.Path. We use anyio.Path so we can do async operations with the Path

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 4, 2024
@jamesbraza jamesbraza merged commit b2fe94e into main Oct 4, 2024
5 checks passed
@jamesbraza jamesbraza deleted the getting-index-location branch October 4, 2024 22:27
jamesbraza added a commit that referenced this pull request Oct 4, 2024
…d `IndexSettings.get_named_index_directory` (#531)
jamesbraza added a commit that referenced this pull request Oct 4, 2024
…d `IndexSettings.get_named_index_directory` (#531)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants