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

Wrap face analysis algorithms in Docker #22

Merged
merged 15 commits into from Aug 8, 2018

Conversation

Projects
None yet
2 participants
@c-w
Copy link
Member

commented Aug 7, 2018

The interface to the algorithm Docker is as follows:

  • The container is directly invoked docker run the_container ...
  • The first and only argument to the container is the path to the image to be analyzed.
  • The container prints a JSON object {"faceVectors":[[...],[...],...]} to stdout.

See #3

@c-w c-w requested review from armanrahman22 and michaelperel Aug 7, 2018

c-w added some commits Aug 8, 2018

Revert back to cleaning up before test run
This prevents potential unexpected behavior due to volumes sticking
around between runs.
Make use of environment variables explicit
This change also makes it easier to override environment variables, e.g.
to configure a queue per test run.
from sqlalchemy.orm import sessionmaker
from sqlalchemy import create_engine
from ..log import get_logger
from ..settings import (MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE,

This comment has been minimized.

Copy link
@michaelperel

michaelperel Aug 8, 2018

Collaborator

In previous PRs, ..imports were replaced with module.module.module. Which should we choose for consistency?

This comment has been minimized.

Copy link
@c-w

c-w Aug 8, 2018

Author Member

I'll fix up all the imports in a follow up PR, keeping local consistency for now. In general, absolute imports are preferred since they are more explicit.

@@ -9,7 +8,8 @@
Integer, DateTime, UniqueConstraint)
from itsdangerous import (TimedJSONWebSignatureSerializer
as Serializer, BadSignature, SignatureExpired)
from .database_manager import DatabaseManager
from .database_manager import get_database_manager
from ..settings import TOKEN_EXPIRATION, TOKEN_SECRET_KEY

This comment has been minimized.

Copy link
@michaelperel

michaelperel Aug 8, 2018

Collaborator

In previous PRs, ..imports were replaced with module.module.module. Which should we choose for consistency?

@@ -53,3 +40,8 @@ def safe_commit(self, session):
def close_engine(self):
self.logger.debug("engine closed")
self.engine.dispose()


@lru_cache(maxsize=1)

This comment has been minimized.

Copy link
@michaelperel

michaelperel Aug 8, 2018

Collaborator

Is the purpose of this decorator (maxsize=1, on a function with no arguments) to treat the DatabaseManager class as a singleton? If so, is this a better way than explicitly making the class a singleton, so it is not accidentally misused?

This comment has been minimized.

Copy link
@c-w

c-w Aug 8, 2018

Author Member

Yes, this is the standard/stdlib way to create a singleton.

This comment has been minimized.

Copy link
@michaelperel

michaelperel Aug 8, 2018

Collaborator

The problem I foresee with this method is that I could still make as many different instantiations of DatabaseManager as I would like. If we made the class an actual singleton (https://www.python-course.eu/python3_metaclasses.php) (could use metaclasses as the link describes, but not totally necessary), then this problem would be alleviated.

This comment has been minimized.

Copy link
@c-w

c-w Aug 8, 2018

Author Member

In dynamic languages you can always shoot yourself in the foot if you want to... it's just about making "doing the right thing" easy. Ideally the design would be changed to avoid the need for the singleton (e.g. currently there are lots of nested sessions etc flying around) but that's a bigger change than I'm willing to make right now.

@c-w c-w merged commit 9a2693b into master Aug 8, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@c-w c-w deleted the docker branch Aug 8, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.