Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made more pacakge friendly, auto model downloader #8

Merged
merged 9 commits into from Apr 29, 2021

Conversation

eddiebergman
Copy link
Contributor

@eddiebergman eddiebergman commented Mar 26, 2021

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: zimmerl@informatik.uni-freiburg.de
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.

@eddiebergman eddiebergman changed the title Made more PyPi friendly Made more pacakge friendly Mar 26, 2021
@eddiebergman eddiebergman changed the title Made more pacakge friendly Made more pacakge friendly, auto model downloader Mar 30, 2021
@arberzela arberzela merged commit 6f5536a into automl:master Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants