-
Notifications
You must be signed in to change notification settings - Fork 238
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
Move 3 newPackage options to beginDocumentation #3390
base: development
Are you sure you want to change the base?
Conversation
e34a89f
to
caaa1b5
Compare
(because it needs qepcad)
@@ -224,6 +225,7 @@ newPackage = method( | |||
UseCachedExampleOutput => null, | |||
Version => "0.0" | |||
}) | |||
newPackage Sequence := opts -> x -> newPackage(x#0, opts) -- to allow null entries |
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.
Would newPackage(String, Nothing)
make sense instead to solve the specific issue of trailing commas?
With the new behavior, I'd be a little concerned that something like newPackage("Foo", 1, 2, 3, 4, 5)
would be allowed.
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.
I feel like methods newPackage
showing (newPackage, Sequence)
is a lot less surprising than (newPackage, String, Nothing)
. I can assert that the other entries are null if you want?
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.
Sure, that works
beginDocumentation = { | ||
CacheExampleOutput => null, | ||
OptionalComponentsPresent => null, | ||
UseCachedExampleOutput => null, -- TODO: not used by any package, retire this! |
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.
I use this option in the Debian package to fix some reproducibility issues and to cache some examples that occasionally crash, so I'd prefer to keep it around.
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.
UseCachedExampleOutput
? Can you say more about how you use it? Maybe I don't understand it well. If cached examples are present, wouldn't M2 automatically use them? (I think it does, e.g. see the single realrank
example that I added)
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.
I think it needs to be true in order to copy any cached examples over:
M2/M2/Macaulay2/m2/installPackage.m2
Lines 556 to 562 in ec9e9ac
-- use distributed example results | |
else if pkgopts.UseCachedExampleOutput | |
and not opts.RerunExamples and fileExists outf' and cmphash(outf', inputhash) then ( | |
if fileExists errf then removeFile errf; | |
copyFile(outf', outf); | |
verboseLog("using cached " | desc) | |
) |
I use it in the Debian package by patching several packages so that OptionalComponentsPresent
is true, and then copying the cached examples from this directory over to the corresponding package directories before building the docs.
@@ -2,7 +2,7 @@ | |||
-- RInterface documentation -- | |||
------------------------------ | |||
|
|||
beginDocumentation() | |||
beginDocumentation(OptionalComponentsPresent => RPresent) |
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.
The builds are failing right now because the RInterface
tests are loaded before this call to beginDocumentation()
and so the OptionalComponentsPresent
package option doesn't exist yet, which causes a problem when calling check
.
A band-aid fix for this specific package would be to switch the order of the two load
lines at the bottom of RInterface.m2
, but I wonder if TEST
should raise an error if the option doesn't exist yet, so we know that we're calling it after beginDocumentation()
.
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.
Actually, that's not quite right. We're calling end
since R isn't found before beginDocumentation()
. This package is unusual in that regard.
But regardless, there should probably be some kind of check (either in TEST
or check
) to make sure that the OptionalComponentsPresent
option exists to avoid strange "key not found" error messages.
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.
I just pushed a fix for the RInterface-specific issue.
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.
Hmm, I think it shouldn't matter where beginDocumentation()
is called. Actually, I tend to prefer defining tests before calling beginDocumentation()
, because I've ran into weird issues where the tests weren't loaded since M2 stopped at beginDocumentation()
. I'm not sure what specific situation caused this though.
For this issue, I think I might prefer treating the absence of OptionalComponentsPresent
as it being true. I think this would solve the failure, no?
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.
Yeah, you're right -- it doesn't matter since we won't be calling check
until after the package is loaded.
Yes, your idea is much better than manually setting it for a specific package like I was doing!
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.
I just pushed an alternate fix based on your suggestion. One of the builds was failing even after the RInterface-specific fix, so it must not be the only package where this was an issue.
For now, I just wanted to make sure all tests passed, but I would like to simplify this further before moving it out of draft mode. Here are a few goals, but feel free to add more:
|
It won't exist if we never called beginDocumentation(), resulting in a "key not found" error.
c8a0c78
to
525b806
Compare
This would be awesome. I have a pretty hacky function that does this for the Debian package, but a cleaner solution would be great. |
This is a draft for now to see what breaks. Comments welcome.
Closes #3369.