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

Move 3 newPackage options to beginDocumentation #3390

Draft
wants to merge 8 commits into
base: development
Choose a base branch
from

Conversation

mahrud
Copy link
Member

@mahrud mahrud commented Aug 5, 2024

This is a draft for now to see what breaks. Comments welcome.

  • fixed newPackage to permit terminal null entries
  • moved 3 newPackage options to beginDocumentation
  • adjusted existing packages with optional components
  • corrected package options in TropicalTorics
  • removed FirstPackage stuff from Polymake.m2
  • unexported two undefined gfanInterface symbols

Closes #3369.

@mahrud mahrud force-pushed the quickfix/optional-components branch from e34a89f to caaa1b5 Compare August 5, 2024 20:43
@@ -224,6 +225,7 @@ newPackage = method(
UseCachedExampleOutput => null,
Version => "0.0"
})
newPackage Sequence := opts -> x -> newPackage(x#0, opts) -- to allow null entries
Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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!
Copy link
Member

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.

Copy link
Member Author

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)

Copy link
Member

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:

-- 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)
Copy link
Member

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().

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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!

Copy link
Member

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.

@mahrud
Copy link
Member Author

mahrud commented Aug 6, 2024

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:

  • keep beginDocumentation() simple, ideally one option only.
  • maybe allow use of cached examples opportunistically, or even provide a function for generating a single cached example, so we can cache only the necessary examples (e.g. realrank is the only one from CoincidenceRootLoci that needs to be cached)
  • simplify the logic in the background, maybe debug mystery issue I described above with tests disappearing after beginDocumentation()
  • think about whether CacheExampleOutputs should be transitive.
  • think about whether readPackage should know whether optional dependencies are present, because with this PR it will not
  • maybe have one distinguished package for each optional dependency so we don't check for existence of the same software in multiple places
  • along the way, stop using type or command and use findProgram
  • bring back the newPackage options for backwards compatibility, but have them give a deprecation warning.

It won't exist if we never called beginDocumentation(), resulting in a
"key not found" error.
@d-torrance d-torrance force-pushed the quickfix/optional-components branch from c8a0c78 to 525b806 Compare August 6, 2024 18:28
@d-torrance
Copy link
Member

or even provide a function for generating a single cached example, so we can cache only the necessary examples

This would be awesome. I have a pretty hacky function that does this for the Debian package, but a cleaner solution would be great.

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