Hi, thanks for the awesome library!
Note: I further added functionality to download the models automatically to save the users any extra steps, this is done in the example as well, please see the note at the bottom.
I did have some issue with paths throughout and installing it as a local package is broken due to:
- The use of relative paths (paths relative to where python is being run, rather than where the nasbench files are)
json
config files not being included when the package is actually installed using pip
- Imports not working as they did not belong to a
module
, a folder containing an __init__.py
file.
This PR essentially makes the library more package friendly by allowing the user to install the library using pip:
# Assuming all requirements met
git clone https://github.com/automl/nasbench301/
pip install ./nasbench301
python -c "import nasbench301"
Fixes
The pull request addressed these issues by:
- Making sure all
json
files required for the code to run are included using a MANIFEST.in
. (docs)
- Adding
__init__.py
files where missing.
- Updating to use paths relative to where the code is using
__file__
.
- Updated
README.md
to take out the requirement of the export PYTHONPATH=$PWD
Benefits
A user should now just be able to import and use nasbench301 as a package as they would any other third-party package downloaded from github, without having to do the export step mentioned in the README.md
. (assuming they have downloaded the nb_models
v0.9 or v1.0)
# ~/myscript.py
import nasbench301
gnngin_model_path = 'path/to/model'
performance_model = nasbench301.load_ensemble(gnngin_model_path)
genome = ...
prediction = performance_model.predict(config=genome, representation='genotype')
print(prediction)
> git clone https://github.com/automl/nasbench301
...
> pip install ./nasbench301
...
> pip show nasbench301
Name: nasbench301
Version: 0.2
Summary: A surrogate benchmark for neural architecture search
Home-page: https://github.com/automl/nasbench301
Author: AutoML Freiburg
Author-email: [email protected]
License: 3-clause BSD
Location: /home/--omitted--/.venv/lib/python3.8/site-packages
Requires:
Required-by:
> python ~/myscript.py
22.41
Test
This was tested with my own code that uses all 3 models. I have also tested this by running the example.py
.
> python -v
Python 3.8.6
> pip -v
pip 20.2.1
Updated Example and Model Downloading
To make it easier to run the example I included a script to download the models and updated the example to use it if the models do not exist.
If the library is installed using pip install nasbench301
, the downloader defaults to deleting the zip files afterwards to prevent any bloat into the environment it's installed into.