Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
345 stars 230 forks source link

OnlineLookup example requires network access #2408

Closed d-torrance closed 2 years ago

d-torrance commented 2 years ago

Network access may not be available during build. For example, from this PPA build:

 -- making example results for "oeis"                                       
 ulimit -c unlimited; ulimit -t 700; ulimit -m 850000; ulimit -s 8192; ulimit -n 512;  cd /tmp/M2-124904-0/1-rundir/; GC_MAXIMUM_HEAP_SIZE=400M "/<<PKGBUILDDIR>>/M2/usr-dist/x86_64-Linux-Ubuntu-21.10/bin/M2-binary" -q --int --no-randomize --no-readline --silent --stop --print-width 77 -e 'needsPackage("OnlineLookup",Reload=>true,FileName=>"/<<PKGBUILDDIR>>/M2/Macaulay2/packages/OnlineLookup.m2")' <"/tmp/M2-124904-0/0_oeis.m2" >>"/<<PKGBUILDDIR>>/M2/usr-dist/common/share/doc/Macaulay2/OnlineLookup/example-output/_oeis.errors" 2>&1
/<<PKGBUILDDIR>>/M2/usr-dist/common/share/doc/Macaulay2/OnlineLookup/example-output/_oeis.errors:0:1: (output file) error: Macaulay2 exited with status code 1
/tmp/M2-124904-0/0_oeis.m2:0:1: (input file)
M2: *** Error 1
 -- 0.255548 seconds elapsed
 -- storing example results in ../../../usr-dist/common/share/doc/Macaulay2/OnlineLookup/example-output/_oeis.out
 -- warning: missing file /<<PKGBUILDDIR>>/M2/usr-dist/common/share/doc/Macaulay2/OnlineLookup/example-output/_oeis.out
../../m2/debugging.m2:23:6:(1):[9]: error: installPackage: 1 error(s) occurred running examples for package OnlineLookup:

_oeis.errors
************
-- -*- M2-comint -*- hash: 1103500785

i1 : oeis {1,3,31,1145}
stdio:1:1:(3): error: can't open socket : Name or service not known

Perhaps this example should be cached?

pzinn commented 2 years ago

.. but https://github.com/Macaulay2/M2/issues/1924 ...

DanGrayson commented 2 years ago

Don't use canned examples, just turn on the options CacheExampleOutput and AuxiliaryFiles to newPackage. Then the next time you install the package, the output files will be cached for you, and you can add them to the repository.

DanGrayson commented 2 years ago

If you want to, you could test for network access and set OptionalComponentsPresent appropriately. That way the example code will be run if possible.

pzinn commented 2 years ago

okay. what's the fastest way of detecting whether there is network access?

DanGrayson commented 2 years ago

Actually, it occurs to me that it's impolite to access the network when software is being built, unless the builder gives permission. That's why the configure script has an enable-download option. Maybe we don't test.

d-torrance commented 2 years ago

Actually, it occurs to me that it's impolite to access the network when software is being built, unless the builder gives permission. That's why the configure script has an enable-download option. Maybe we don't test.

Apologies for hijacking, but related to this -- building the JavaScript file for syntax highlighting (from #2391) requires network access (for npm install). Should this be turned off by default?

DanGrayson commented 2 years ago

Does that imply that there's an error on a machine without network access that prevents Macaulay2 from being built?

What's npm?

d-torrance commented 2 years ago

Does that imply that there's an error on a machine without network access that prevents Macaulay2 from being built?

What's npm?

npm is the "Node Package Manager", for dealing with JavaScript packages. Here's the current behavior:

Perhaps the latter should be the default, even if npm is available, and the former only when --enable-download is given to configure?

DanGrayson commented 2 years ago

I've never installed npm here, and I haven't seen any builds fail.

We want to be able to build without network access. So we could either include the needed files in our source tree, or include the installation of npm and the running of npm install as part of the INSTALL instructions for the builder.

d-torrance commented 2 years ago

I've never installed npm here, and I haven't seen any builds fail.

We want to be able to build without network access. So we could either include the needed files in our source tree, or include the installation of npm and the running of npm install as part of the INSTALL instructions for the builder.

Sounds good -- I'll work on something here soon.

pzinn commented 2 years ago

OK so I'm not going to test for network access. I'm okay with caching the example anyway, but I find the documentation of newPackage confusing. it says:

UseCachedExampleOutput => a Boolean value, default value null, whether installPackage should copy previously cached example output, if it is present and corresponds to the current example input for a node, rather than rerunning the examples, which might be important if optional external software is not present in the system. This is relevant only when CacheExampleOutput and AuxiliaryFiles are set to true. Unless set by the user, it is set to the negation of the value of OptionalComponentsPresent.

but the default value of OptionalComponentsPresent is null, it says right above... For now I'll just set CacheExampleOutput to true and not worry about UseCachedExampleOutput...

d-torrance commented 2 years ago

This was fixed in #2415