moto==1.1.15 not bundling 'moto/ec2/resources/instance_types.json'

Created on 27 Sep 2017  路  16Comments  路  Source: spulec/moto

When moto resolves to version 1.1.15, I am seeing an issue where moto cannot find a resource I would expect to be bundled with the distribution. Pinning to moto==1.1.14 resolves the issue.

See the following traceback exhibited by 1.1.15:

test_usercode.py:2: in <module>
    import moto
../.tox/testenv/lib/python3.5/site-packages/moto/__init__.py:8: in <module>
    from .acm import mock_acm  # flake8: noqa
../.tox/testenv/lib/python3.5/site-packages/moto/acm/__init__.py:2: in <module>
    from .models import acm_backends
../.tox/testenv/lib/python3.5/site-packages/moto/acm/models.py:7: in <module>
    from moto.ec2 import ec2_backends
../.tox/testenv/lib/python3.5/site-packages/moto/ec2/__init__.py:2: in <module>
    from .models import ec2_backends
../.tox/testenv/lib/python3.5/site-packages/moto/ec2/models.py:115: in <module>
    INSTANCE_TYPES = json.load(open(os.path.join(RESOURCES_DIR, 'instance_types.json'), 'r'))
E   FileNotFoundError: [Errno 2] No such file or directory: '/<userpath>/.tox/testenv/lib/python3.5/site-packages/moto/ec2/resources/instance_types.json'

Most helpful comment

Thank you, @kevinfrommelt once again!

All 16 comments

Good catch! This is a recent regression and I'll fix it right now.

Fixed on master. Releasing 1.1.16 when tests pass

1.1.16 released, please use that

Still hitting this. I downloaded the latest tar.gz and that file is not in it.

FWIW, this is still broken in 1.1.16 for us, too. I had to pin moto==1.1.14 in our test suite (for now).

Understood. Investigating right now.

Probably fixed here: #1209
Releasing a new version shortly.

Alternatively you could include the json file via the MANIFEST.in https://github.com/spulec/moto/compare/master...kevinfrommelt:fix-missing-json

Thanks to @kevinfrommelt this is now fixed in Moto version 1.1.18. Go team!

I've been seeing this issue earlier in the morning. I re-ran a test suite using the up to date package (moto==1.1.18), but I get back the same traceback.

_____________________ ERROR collecting tests/test_utils.py _____________________
tests/test_utils.py:5: in <module>
    from moto import mock_s3
.tox/py27/lib/python2.7/site-packages/moto/__init__.py:8: in <module>
    from .acm import mock_acm  # flake8: noqa
.tox/py27/lib/python2.7/site-packages/moto/acm/__init__.py:2: in <module>
    from .models import acm_backends
.tox/py27/lib/python2.7/site-packages/moto/acm/models.py:7: in <module>
    from moto.ec2 import ec2_backends
.tox/py27/lib/python2.7/site-packages/moto/ec2/__init__.py:2: in <module>
    from .models import ec2_backends
.tox/py27/lib/python2.7/site-packages/moto/ec2/models.py:115: in <module>
    INSTANCE_TYPES = json.load(open(os.path.join(RESOURCES_DIR, 'instance_types.json'), 'r'))
E   IOError: [Errno 2] No such file or directory: u'/home/travis/build/mozilla/python_mozetl/.tox/py27/lib/python2.7/site-packages/moto/ec2/resources/instance_types.json'

@JackDanger Looks like the file is in the package, but not being installed with the source code. I believe setting this flag in the setup.py will fix this https://github.com/spulec/moto/compare/master...kevinfrommelt:fix-missing-json

I created a package locally with that change via python setup.py sdist and installed the package into a new virtualenv. I was able to import moto and confirmed that json file was installed in the virtualenv

Thank you, @kevinfrommelt once again!

Released as Moto 1.1.19

1.1.19 is working for me.

1.1.19 works on my end too. Thanks for the speedy response!

Was this page helpful?
0 / 5 - 0 ratings