Conversation
mathics/doc/common_doc.py
Outdated
|
|
||
|
|
||
| def check_requires_list(requires: list) -> bool: | ||
| global requires_cache |
There was a problem hiding this comment.
I put this for clarity, but OK.
There was a problem hiding this comment.
Huh? There is no variable requires_cache. The typical way of adding clarity is in a docstring. For example:
"""
Check if module names in ``requires`` can be imported and return True if they can or False if not.
This state value is also recorded in dictionary `requires_lib_cache` keyed by module name and is used to determine whether to skip trying to get information from the module.
"""
There was a problem hiding this comment.
You are right! I changed the name. The variable was requires_lib_cache, which was defined just above.
There was a problem hiding this comment.
Since mathics.builtin.base also benefits from using check_requires_list I moved the code there.
mathics/doc/common_doc.py
Outdated
| == self.pymathicsmodule.__name__ | ||
| ): # nopep8 | ||
| if not check_requires_list(var): | ||
| print(" skiping ", var.__name__) |
There was a problem hiding this comment.
skiping -> skipping. But I'd be more explicit to why it is skipped, an optional package is not installed.
There was a problem hiding this comment.
This print actually never happens, because we are not generating documentation for pymathics modules. I just removed it.
|
Overall this looks good and is much needed. I'd like to try it out though and haven't had a chance. |
mathics/doc/common_doc.py
Outdated
| Check if module names in ``requires`` can be imported and return True if they can or False if not. | ||
|
|
||
| This state value is also recorded in dictionary `requires_lib_cache` keyed by module name and is used to determine whether to skip trying to get information from the module.""" | ||
| global requires_lib_cache |
There was a problem hiding this comment.
This is what I had in mind. Having or not this line does not seems to change anything, just to state that require_lib_cache is a variable at the level of the module.
There was a problem hiding this comment.
Please don't add a global. It is frowned upon generally. Some would argue that this should be passed as a parameter, and that is the typical way you convey this - in the interface.
I know this kind of thing, a creative use of global seems innovative and clever. Along those lines, I used to (and still sometimes do) add pass statements where in most programming languages an end closer would appear. However it puts off most programmers so I generally don't do it except in code where I am pretty much the only one who will ever use this.
There is a place for creativity, but here and this way sadly isn't the place for that.
There was a problem hiding this comment.
It was not about creativity, but being more verbose about what I am changing here. I think the new place of this stuff in mathics.builtin.basealso goes in this direction.
There was a problem hiding this comment.
Regarding this, probably the cache for the previous results is not needed: Python have also a cache inside importlib, so the global variable does not provide too much advantage.
Actually, there are several things to improve in this module, but I refrain to do it in order to make this PR as simple as possible to get something that works with the basic Pyston test workflow. |
Sure. Yes, it is useful when working with Pyston which I think will be doing more of in the futre. I just want to double check and try it so there isn't something kind of silly like there |
Please record those items as issues. Thanks. I just tried without |
this is in this branch? |
I believe so: |
4fde248 to
2ed335b
Compare
Now I added a workflow testing against a basic installation of Python 3.9 in ubuntu. #368 should show that this also works in Pyston. |
That is a draft and this isn't. That may show that there is a particular way to install Pyston that works. However I've been running Pyston with scikit-image installed for a while even without this PR. What i am wondering about though is whether this addresses the problem I encountered. Not whether there is some scenario where we can make pyston work. It would help if you can describe a specific setup and test case where things were failing without this patch and then with this they don't fail. |
No: the idea is not to show that Pyston can run with scikit-image, but that can run without it.
With master, if scikit image is not installed, there are tests that fail (as you show above). However, we say that scikit is an optional package, so the CI should show in green if the environment does not have scikit available. The same happens with scipy. This PR fixes that and shows that it works by adding a workflow that has a minimal installation. |
|
The problem with having a workflow with the full set of libraries in Pyston is that most of the time is invested in recompiling scipy, scikit and other heavy libraries. When that libraries are available, then the tests that assume that the libraries are there run. I am looking for possibilities for downloading a preinstalled environment with all the optional libraries, but still I have not give with a solution. On the other hand, if we are looking to do performance tests in the evaluation process, I think that also makes sense to check it over a minimal environment. |
|
@rocky, in #370 I tried a workflow for Pyston with the full set of optional libraries. It took ~60 min, against ~6 min with the reduced set (#368). 48 minutes were used to compile the libraries.
@rocky, in #370 I tried a workflow for Pyston with the full set of optional libraries. It took ~60 min, against ~6 min with the reduced set (#368). 48 minutes were used to compile the libraries. So, if we are trying to check that the mathics core runs properly in Pyston, I think we should try it against the basic installation. There is where this PR is needed: if you just add the workflow to master, several tests are not passed (like the ones in the |
| @@ -0,0 +1,34 @@ | |||
| name: Mathics (ubuntu-minimal) | |||
There was a problem hiding this comment.
This workflow was added to check that indeed with the changes the tests pass with a minimal installation.
|
Superseeded. |
This PR is a previous step for adding a Pyston test workflow (see #368). The proposed changes allow skipping the tests associated with symbols whose evaluation requires not available external libraries.
To check that indeed this works with a minimal environment, I added here a workflow to check that in standard Ubuntu Python.