Closed vmarois closed 6 years ago
Closes #5
Thanks for that great pull request.
Generally, I think that: a) let's stay with the current content of the outermost init file for now, b) creating an issue regarding the absolute paths of configuration files.
In this PR, I'm adding the
setup.py
script for the installation ofmip
. This should lower the entry bar formi-prometheus
(python setup.py install
) and let external users easily use it. It should also allow to upload the framework to PyPI (by creating a wheel withpython setup.py sdist bdist_wheel
- though I haven't tested it).The main points are:
workers/
,problems/
,models/
,utils/
into a directorymiprometheus/
. This is a major change which impacts the structure ofmip
as aPython
package. I did this as the use of thesetup.py
authorizes the user to import the packages & modules of Mi-Prometheus. They are now all undermiprometheus/
, which enables the user to simplyimport miprometheus as mip
to have access to all classes in his workspace. This is a screenshot of what the user would be able to do:It is working well, and for now, all models / problems are
import
-able directly frommiprometheus.models
/miprometheus.problems
respectively. This is due to the fact that all classes (and then modules) are imported from the innermost__init__
to the outermost one. This may change in the future as it appears that having too many statements in the__init__
s is not best practice: See here:So I would support emptying the outermost
__init__
s, as this could avoidimport
issues, and force theimport
statements to reflect more closely the project structure. On a similar topic, I would also support simplifying theproblems
directory (especiallyseq_to_seq
) as it is too nested for me. My argument is that thesetup.py
exposesmiprometheus
as a regular API to the user (like most packages out there). While I agree that this is not the main use-case ofmiprometheus
(which is through the scripts, see point below), we still should maintain it as it may be how a user would test integrating a new problem / model inmiprometheus
(with first the use of a decorator@register
and then cloning the repo to fully integrate it in the source code). For the others entities inmiprometheus
, it is not as critical as the directories aren't as nested. An import likefrom miprometheus.models.mac import MACNetwork
is sufficiently short & clear to me.This is an example with
mip-offlinetrainer --h
and similarly, you'll havemip-gridtester-cpu
etc. :warning: As of now, there is an error related to the paths of thedefault_config
files (they are treated as absolute paths), which should be easily fixable. Also, thesetup.py
has the option to install datafiles:package_data={ # 'mip.config': ['default_config.yaml'] }
So perhaps that gives the option to list here someconfigs.yaml
files that will be copied over with the data and thus accessible from everywhere. I'll look into that later on.python setup.py install
command using a Docker image of Ubuntu 16.04. One main thing is that we should not usepytorch
frompip
, as it causes errors that shouldn't appear (I have seen this on others python projects as well). So installingpytorch
from miniconda and then using thesetup.py
to install the rest of the dependencies works and does not cause issues. I have tested a run of MAES on SerialRecall & a run of SimpleConvNet on MNIST, which both converged and were tested withmip-tester
.I have encountered some (easily fixable) errors, related to
matplotlib
, and the backend it uses (related toPyQt5
). The unique class which causes this isTimePlot
(and I strongly advocate that it gets refactored to address this + becomes more efficient).mip
. Mainly I removedprogressbar2
&pandas
+ the call to openinglogger_config.yaml
in the base workers classes (the content of this file is now directly adict
variable contained in the classes that use it,Worker
&GridWorker
). The minimal dependencies needed to usemip
are:I recommend that you look at the
setup.py
to see which information are located here.Feedback welcome!
Note:
Python3.6
.readthedocs.yml
file needed to build the doc, but as of now, readthedocs.io is still affected by the GitHub outage. So waiting for it to be back to normal to test the doc build.