-
Notifications
You must be signed in to change notification settings - Fork 208
FIX Allow str path minigallery entries when backreferences off #1355
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
Conversation
@larsoner will release after this FYI |
GitHub ate my review comment, but my guess is I wrote that error message when I was trying to debug relative paths, so I'd put in "../../examples" as input and the example dir would be "/examples" and I think wording could be "no matched found for {dir}, files must be in {example_dir}". |
As input to the minigallery directive? But would glob find anything if it was the wrong relative path? |
This error gets triggered when it doesn't find anything(the condition is !=1) |
Sorry I mean if the input is wrong the glob above would not find anything: sphinx-gallery/sphinx_gallery/directives.py Line 105 in 2fc5067
I guess it could find a file, but not inside the I don't know in what case Edit: I guess you could have 2 |
fun bit about using relative paths - same file inside the examples_dir folder, but the paths don't evaluate to the same path , but agree that "no matches found for {dir}, files must be in {example_dir}" wording would probably be better.
So I think this is cause obj.find(e) can be stupidly brittle but I couldn't think of a better way to do this bit - I think something like input needs to be relative path but making the thumbnail needed this path - an improvement/follow up if I have time would be to make a list of (example/thumbnail/intro/title) so examples don't need to get reparsed here and that would probably clean up some of this. |
sorry I do not follow what you mean. Can you give an example?
Are you are talking about: sphinx-gallery/sphinx_gallery/directives.py Line 151 in 2fc5067
Could you give an example? E.g., if I wanted to test this error, what would the test look like? |
this will trigger the error: f"Error in minigallery file lookup: input path {obj} matches to {dirs}. Input must be start with one of the following paths: {examples_dirs}" |
Also apparently originally this was written specifically for the >1 case (#1226 (comment)) which I can't seem to trigger so 🤷♀️ what it's supposed to communicate is I think something like "incorrect or ambiguous input, can't resolve to matching examples folder" |
< 8000 span class="Button-content">
I get this error:
But again we are in the case where there are NO matches - i.e., glob found files, but the files aren't in What is an example of a case where there are >1 matches? Edit: just saw:
|
@@ -67,12 +70,16 @@ def run(self): | |||
# Retrieve the backreferences directory | |||
config = self.state.document.settings.env.config | |||
backreferences_dir = config.sphinx_gallery_conf["backreferences_dir"] | |||
if backreferences_dir is None: | |||
logger.warning( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also possibly silly question, but I note a self.warning
(using Directive.warning
) used above - in what case should we be using the Directive
warning and in what case should we be using our logger?
I tried self.warning
and it did not output during build. Where does the warning output to when self.warning
is used ..?
Okay I think I'm going to open another issue for the match error, because it probably shouldn't hold up this PR. This is ready for review/merge. I just had a question about warnings: #1355 (comment) (thank you 🙏 ) |
Honestly can't come up w/ one, so my guess is that a refactor of code before this point maybe made this case unreachable but not sure. 🙃 |
Let's continue the conversation in #1356 @story645 any insights on #1355 (comment) ? I see you use a |
Pretty sure that code was in the directive before I touched it, I just added the ExtensionError, sorry :/ either that or I copy/pasted it from @melissawm's implementation of a different directive. |
re-reading, could you expand? Where would the list live? |
I was thinking json file or the like, and not sure where - figure that would be part of PR discussion. |
Ah okay, maybe with the thumbnail images as image metadata. But we'd have to consider whether it's worth all the extra work generating the files, performance wise (especially as some projects may not use the minigallery directive). Anyway, things to consider. @larsoner I'll merge this next week, in case you want to take a look. 8000 |
Yeah, I figure I can open an issue w/ a more thought out proposal if there's soft support & this can be configurable (cache_gallery_entries) |
Merging this. I think there is no need to add extra checks to prevent us from glob-ing object inputs:
But @larsoner let me know if you disagree! |
… to version 0.17.1 v0.17.1 ------- **Fixed bugs:** - FIX: Fix stability of stored compiled regex `#1369 <https://github.com/sphinx-gallery/sphinx-gallery/pull/1369>`__ (`larsoner <https://github.com/larsoner>`__) - ENH: Improve \_sanitize_rst `#1366 <https://github.com/sphinx-gallery/sphinx-gallery/pull/1366>`__ (`timhoffm <https://github.com/timhoffm>`__) - Obey prefer_full_module setting when finding backreferences `#1364 <https://github.com/sphinx-gallery/sphinx-gallery/pull/1364>`__ (`QuLogic <https://github.com/QuLogic>`__) - Fix linking to class attributes with prefer_full_module `#1363 <https://github.com/sphinx-gallery/sphinx-gallery/pull/1363>`__ (`QuLogic <https://github.com/QuLogic>`__) - Improve minigallery directive path input resolution `#1360 <https://github.com/sphinx-gallery/sphinx-gallery/pull/1360>`__ (`lucyleeow <https://github.com/lucyleeow>`__) - FIX Allow str path minigallery entries when backreferences off `#1355 <https://github.com/sphinx-gallery/sphinx-gallery/pull/1355>`__ (`lucyleeow <https://github.com/lucyleeow>`__) - FIX generate zipfiles when index passed by user `#1353 <https://github.com/sphinx-gallery/sphinx-gallery/pull/1353>`__ (`lucyleeow <https://github.com/lucyleeow>`__) **Documentation** (NEWS truncated at 15 lines)
Closes #1354
Amend the minigallery directive, such that when
backreferences_dir
isNone
, we simply treat all entries as str paths and glob them.I thought about adding additional check to the minigallery entries, to make sure they are not objects. But it would be very unusual to have a file named e.g.,
sphinx_gallery.sorting.ExplicitOrder
in the source dir?Happy to add a check though, WDYT @larsoner ?
Also fixes a bug where we were not converting
examples_dirs
andgallery_dirs
to list when given as str.Note to self: look into: #1226 (comment)