Skip to content

Result permissions #2

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

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/grid.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# $ docker run -it -p 5000:5000 openmined/grid-network

ARG VERSION=latest
FROM openmined/syft:$VERSION
FROM syft:$VERSION

# envs and args
ARG APP
Expand Down
36 changes: 36 additions & 0 deletions docker/gridlocaldb.DockerFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#### INSTRUCTIONS
# BUILD the syft base image first

# for DEV mode, editable source and hot reloading
# $ docker build -f docker/grid.Dockerfile --build-arg APP=domain --build-arg APP_ENV=dev -t openmined/grid-domain-dev:latest -t openmined/grid-domain-dev:`python VERSION` .
# $ docker run -it -v "`pwd`/packages/grid/apps/domain:/app" -v "`pwd`/packages/syft:/syft" -p 5000:5000 openmined/grid-domain-dev

# for PROD mode, non editable and smaller
# $ docker build -f docker/grid.Dockerfile --build-arg APP=domain --build-arg APP_ENV=production --build-arg VERSION=`python VERSION` -t openmined/grid-domain:latest -t openmined/grid-domain:`python VERSION` .
# $ docker run -it -p 5000:5000 openmined/grid-domain

# for PROD mode, non editable and smaller
# $ docker build -f docker/grid.Dockerfile --build-arg APP=network --build-arg APP_ENV=production --build-arg VERSION=`python VERSION` -t openmined/grid-network:latest -t openmined/grid-network:`python VERSION` .
# $ docker run -it -p 5000:5000 openmined/grid-network

ARG VERSION=latest
FROM openmined/syft:$VERSION

# envs and args
ARG APP
ARG APP_ENV=production
ENV APP_ENV=$APP_ENV
ENV DATABASE_URL=sqlite:///nodedatabase.db
ENV PORT=5000

RUN --mount=type=cache,target=/root/.cache python3 -m pip install poetry

# copy and setup app
RUN mkdir -p /app
COPY ./packages/grid/apps/$APP /app
RUN cd /app && poetry export -f requirements.txt --output requirements.txt --without-hashes
RUN --mount=type=cache,target=/root/.cache pip install -r /app/requirements.txt
RUN pip install psycopg2-binary

# run the app
CMD ["bash", "-c", "cd /app && ./run.sh"]
2 changes: 2 additions & 0 deletions packages/grid/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ To start the PyGrid Node manually, run:
```
cd apps/node
./run.sh --id bob --port 5000 --start_local_db

flask run --host=0.0.0.0 --port=5000 --start_local_db
```

You can pass the arguments or use environment variables to set the network configs.
Expand Down
3 changes: 1 addition & 2 deletions packages/grid/apps/domain/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ boto3 = "^1.14.51"
textwrap3 = "^0.9.2"
requests-toolbelt = "0.9.1"
scipy = "^1.6.1"
tenseal = "^0.3.2"
untokenize = "^0.1.1"

[tool.poetry.dev-dependencies]
Expand All @@ -49,5 +48,5 @@ flake8 = "^3.8.3"
flake8-comprehensions = "^3.2.3"

[build-system]
requires = ["poetry>=0.12"]
requires = ["setuptools", "poetry>=0.12"]
build-backend = "poetry.masonry.api"
40 changes: 20 additions & 20 deletions packages/grid/apps/domain/run.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/bin/bash

if [ "$APP_ENV" = "dev" ]; then
# enable hot reloading
export FLASK_ENV=development

# use this function as the entry point
APP_SRC=$(pwd)/src
export FLASK_APP=${APP_SRC}/app.py:create_app

# --start_local_db
export LOCAL_DATABASE=$LOCAL_DATABASE

# allow app imports from the site-packages
export PYTHONPATH="${PYTHONPATH}:${APP_SRC}"

# run
flask run --host=0.0.0.0 --port=$PORT
fi
# enable hot reloading
export FLASK_ENV=development

if [ "$APP_ENV" = "production" ]; then
exec gunicorn --chdir ./src -k flask_sockets.worker --bind 0.0.0.0:$PORT wsgi:app "$@"
fi
# use this function as the entry point
APP_SRC=$(pwd)/src
export FLASK_APP=${APP_SRC}/app.py:create_app

# --start_local_db
export LOCAL_DATABASE=true

# allow app imports from the site-packages
export PYTHONPATH="${PYTHONPATH}:${APP_SRC}"

# run
flask run --host=0.0.0.0 --port=5000

# fi

# if [ "$APP_ENV" = "production" ]; then
# exec gunicorn --chdir ./src -k flask_sockets.worker --bind 0.0.0.0:$PORT wsgi:app "$@"
# fi
4 changes: 3 additions & 1 deletion packages/grid/apps/domain/src/main/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def create_domain_app(app, args, testing=False):
test_config = None

if args.start_local_db:
test_config = {"SQLALCHEMY_DATABASE_URI": "sqlite:///nodedatabase.db"}
print("USING IN MEMORY DB")
test_config = {"SQLALCHEMY_DATABASE_URI": "sqlite:///"}

# Bind websocket in Flask app instance
sockets = Sockets(app)
Expand Down Expand Up @@ -139,6 +140,7 @@ def create_domain_app(app, args, testing=False):
node = GridDomain(name=args.name)

# Set SQLAlchemy configs
print(test_config)
set_database_config(app, test_config=test_config)
app.app_context().push()
db.create_all()
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/apps/domain/src/main/core/nodes/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from syft.core.node.domain.domain import Domain
from syft.grid.connections.http_connection import HTTPConnection
import sympc
import tenseal as ts
# import tenseal as ts

# grid relative
from ..database import db
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/apps/domain/src/main/core/nodes/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from syft.grid.client.client import connect
from syft.grid.client.grid_connection import GridHTTPConnection
from syft.grid.connections.http_connection import HTTPConnection
import tenseal as ts
# import tenseal as ts

# grid relative
from ..database import db
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def create_initial_setup(
msg: CreateInitialSetUpMessage, node: AbstractNode, verify_key: VerifyKey
) -> CreateInitialSetUpResponse:
# Should not run if Domain has an owner
print("AAAA")
if len(node.users):
print(node.users.first())
# print(node.users[0])
raise OwnerAlreadyExistsError

_email = msg.content.get("email", None)
Expand Down
2 changes: 1 addition & 1 deletion packages/grid/apps/domain/src/main/routes/setup/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def initial_setup(current_user):
content = request.get_json()
if not content:
content = {}

status_code, response_msg = error_handler(
route_logic, 200, CreateInitialSetUpMessage, current_user, content
)
Expand Down
Loading