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

Fix dependencies overhead #2346

Closed
wants to merge 9 commits into from

Conversation

slafs
Copy link
Contributor

@slafs slafs commented Jul 30, 2019

This is the initial approach of fixing #1728 i.e. resolve the dependencies overhead and allow for installing minimal set of dependencies for a given service (e.g. when using only s3 backend, install dependencies used by moto.s3 module only).

Currently this is backwards incompatible (!!!)
and probably fails on some tests.

Before I start any efforts on backwards compat, I'd like to get some guidance on how to progress with this, first.

In order to reduce required dependencies we need to change the way we're accessing mock decorators (in moto/__init__.py) and the way we import backends (in moto/backends.py).
This might need an API change, so instead of doing from moto import mock_s3 we'd need to go for from moto.s3 import mock_s3.

BTW This PR reduces the time needed for import moto from 3.5 seconds to 0.5s (on my machine).

Things to discuss/decide:

  • is this approach even feasible for @spulec
  • should we use the new _backends variable or how we should avoid using it?
  • do we still need botocore.awsrequest and ConnectionCls fix in moto/__init__.py (why do we need it anyway)?
  • do we want to include ALL services in extras_require (in setup.py)?
  • can we trim down more dependencies (i.e. remove any from install_requires still, e.g. werkzeug or Jinja2)?

@slafs slafs mentioned this pull request Jul 30, 2019
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 92.964% when pulling f710c7b on slafs:moto-1728/dependencies-overhead into e4a4e61 on spulec:master.

@edisongustavo
Copy link
Contributor

Hello @slafs , if there is something I can do to help get this PR merged, I'm happy to help.

@edisongustavo
Copy link
Contributor

This might need an API change, so instead of doing from moto import mock_s3 we'd need to go for from moto.s3 import mock_s3.

What about a potential workaround to this be, on moto/__init__.py, to avoid breaking the API:

def mock_s3():
    from . import s3
    return s3.mock_s3()

@slafs
Copy link
Contributor Author

slafs commented Jan 6, 2020

Hello @slafs , if there is something I can do to help get this PR merged, I'm happy to help.

Hey @edisongustavo. Thanks for the offer. At this point I think I'd like some input from someone responsible for this codebase, so we get at least an initial acceptance for this work. I guess I'd like some help on keeping this PR fresh (i.e. rebasing on top of spulec:master).

What about a potential workaround to this be, on moto/init.py, to avoid breaking the API:

Good idea! I'll try to incorporate this here. Then it should be easier to keep the PR up-to-date as well.

@slafs
Copy link
Contributor Author

slafs commented May 31, 2020

Closing in favor of #2697 and #2676

@slafs slafs closed this May 31, 2020
@slafs slafs deleted the moto-1728/dependencies-overhead branch May 31, 2020 16:38
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.

3 participants