Le samedi 7 avril 2018 13:06:07 UTC+2, Simon King a écrit :
>
> On 2018-04-07, Thierry <sage-goo...@lma.metelu.net> wrote: 
> > I am sorry to insist, but what is wrong with adding 
> > 
> > # optional -- internet 
> > 
> > on doctests that might connect to the internet ? 
>
> 1. As I was reminded by Jeroen, internet access is blocked during package 
> installation. The tests of my spkg happen during package installation. 
> Thus, internet will NOT be an available option for the tests. 

Internet will not be available... when they are run as part of the 
installation.
Even if they ran during the installation, any user could also run them after
the installation, at which time internet might be available.

> 2. The vast majority of my spkg's tests start with calling a function 
> that is responsible for providing data on a cohomology ring; if the 
> data is locally available, then it is just loaded; if it isn't, but 
> internet is available, then the data is downloaded; if it isn't, then 
> the data is computed from scratch. So, mathematically the functions do 
> not depend on the data from internet; but they do try to access them 
> unless local data are available (which in many tests aren't). 

Maybe such a function could take optional arguments such as

    def f(..., get_data_from=None)
        """
        ...

        INPUT:

        - ``get_data_from`` -- a string, or None
        ...
        The optional argument ``get_data_from`` is a string
        to specify where to try and get the data from, and
        in which order, separated by spaces. Available options
        are 'local_db', 'web_db', 'compute'. The default is to
        first try to access a local database, then a web database,
        then to compute.
        ...
        """
        if get_data_from is None:
            get_data_from = 'local_db web_db compute'
        ...

Then the doctests could be split into some that require internet
(which would be tagged # optional -- internet), and some that don't.

Also, your functions could check the value of a special variable,
say P_GROUP_COHOMOLOGY_SPKG_FORBID_WEB_ACCESS, which users could set
in any Sage session or in their ``init.sage``. In that case, after the
above "if get_data_from is None" block, there could be another block:

        if P_GROUP_COHOMOLOGY_SPKG_FORBID_WEB_ACCESS:
            get_data_from.replace('web_db', '')

> Corollary to 1. and 2.: Marking the tests with 
> # optional -- internet 
> would mean to nuke most of the tests. And that's not acceptable. 
>
> In principle it is not a problem for my spkg that internet is not 
available 
> during package installation. The problem is that in some settings, 
> urllib2 does not realise that internet is not available. That's why it 
> hangs. If it would just raise an error after a few milliseconds then all 
> would be good. 
>
> Best regards, 
> Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to