-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added renku service with cache and datasets
- Loading branch information
Showing
22 changed files
with
1,930 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM python:3.7-alpine | ||
|
||
RUN apk add --update --no-cache alpine-sdk g++ gcc linux-headers libxslt-dev python3-dev build-base openssl-dev libffi-dev git && \ | ||
pip install --no-cache --upgrade pip setuptools pipenv requirements-builder | ||
|
||
RUN apk add --no-cache --allow-untrusted \ | ||
--repository http://dl-cdn.alpinelinux.org/alpine/latest-stable/community \ | ||
--repository http://dl-cdn.alpinelinux.org/alpine/latest-stable/main \ | ||
--repository http://nl.alpinelinux.org/alpine/edge/community \ | ||
git-lfs && \ | ||
git lfs install | ||
|
||
COPY . /code/renku | ||
WORKDIR /code/renku | ||
RUN requirements-builder -e all --level=pypi setup.py > requirements.txt && pip install -r requirements.txt && pip install -e . && pip install gunicorn | ||
|
||
|
||
ENTRYPOINT ["gunicorn", "renku.service.entrypoint:app", "-b", "0.0.0.0:8080"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM python:3.6 | ||
ADD . /app | ||
WORKDIR /app | ||
RUN pip install -e . | ||
EXPOSE 8000 | ||
CMD ["gunicorn", "-b", "0.0.0.0:8000", "app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright 2019 - Swiss Data Science Center (SDSC) | ||
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and | ||
# Eidgenössische Technische Hochschule Zürich (ETHZ). | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Renku service.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright 2019 - Swiss Data Science Center (SDSC) | ||
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and | ||
# Eidgenössische Technische Hochschule Zürich (ETHZ). | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Renku service config.""" | ||
import os | ||
import tempfile | ||
from pathlib import Path | ||
|
||
INVALID_PARAMS_ERROR_CODE = -32602 | ||
INTERNAL_FAILURE_ERROR_CODE = -32603 | ||
|
||
API_VERSION = 'v1' | ||
|
||
SWAGGER_URL = '/api/docs' | ||
API_URL = os.getenv( | ||
'RENKU_SVC_SWAGGER_URL', '/api/{0}/spec'.format(API_VERSION) | ||
) | ||
|
||
UPLOAD_FOLDER = tempfile.TemporaryDirectory() | ||
|
||
CACHE_UPLOADS_PATH = Path(UPLOAD_FOLDER.name) / Path('uploads') | ||
CACHE_PROJECTS_PATH = Path(UPLOAD_FOLDER.name) / Path('projects') | ||
|
||
ALLOWED_EXTENSIONS = {'txt', 'pdf', 'csv'} | ||
|
||
JWT_ALGORITHM = 'HS256' | ||
JWT_KEY = 'renku-svc-secret-key' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright 2019 - Swiss Data Science Center (SDSC) | ||
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and | ||
# Eidgenössische Technische Hochschule Zürich (ETHZ). | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Renku service entry point.""" | ||
import os | ||
import uuid | ||
|
||
from flask import Flask | ||
from flask_swagger_ui import get_swaggerui_blueprint | ||
|
||
from renku.service.config import API_URL, API_VERSION, CACHE_PROJECTS_PATH, \ | ||
CACHE_UPLOADS_PATH, SWAGGER_URL, UPLOAD_FOLDER | ||
from renku.service.views.cache import clone_repository_view, \ | ||
list_projects_view, list_uploaded_files_view, upload_files_view | ||
from renku.service.views.datasets import add_file_to_dataset_view, \ | ||
create_dataset_view, list_dataset_files_view, list_datasets_view | ||
from renku.service.views.docs import api_docs_view | ||
|
||
|
||
def make_cache(): | ||
"""Create cache structure.""" | ||
sub_dirs = [CACHE_UPLOADS_PATH, CACHE_PROJECTS_PATH] | ||
|
||
for subdir in sub_dirs: | ||
if not subdir.exists(): | ||
subdir.mkdir() | ||
|
||
|
||
def create_app(): | ||
"""Creates a Flask app with necessary configuration.""" | ||
app = Flask(__name__) | ||
app.secret_key = os.getenv('RENKU_SVC_SERVICE_KEY', uuid.uuid4().hex) | ||
|
||
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER.name | ||
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 | ||
|
||
make_cache() | ||
build_routes(app) | ||
|
||
return app | ||
|
||
|
||
def build_routes(app): | ||
"""Register routes to given app instance.""" | ||
swaggerui_blueprint = get_swaggerui_blueprint( | ||
SWAGGER_URL, API_URL, config={'app_name': 'RenkuSvc'} | ||
) | ||
|
||
app.register_blueprint(swaggerui_blueprint, url_prefix=SWAGGER_URL) | ||
|
||
app.add_url_rule( | ||
'/api/{0}/spec'.format(API_VERSION), | ||
'docs', | ||
api_docs_view, | ||
methods=['GET'] | ||
) | ||
|
||
app.add_url_rule( | ||
'/cache/files-list', | ||
'list_files', | ||
list_uploaded_files_view, | ||
methods=['GET'] | ||
) | ||
|
||
app.add_url_rule( | ||
'/cache/files-upload', | ||
'upload_files', | ||
upload_files_view, | ||
methods=['POST'] | ||
) | ||
|
||
app.add_url_rule( | ||
'/cache/project-clone', | ||
'clone_project', | ||
clone_repository_view, | ||
methods=['GET'] | ||
) | ||
|
||
app.add_url_rule( | ||
'/cache/project-list', | ||
'list_projects', | ||
list_projects_view, | ||
methods=['GET'] | ||
) | ||
|
||
app.add_url_rule( | ||
'/datasets/list', 'list_datasets', list_datasets_view, methods=['GET'] | ||
) | ||
|
||
app.add_url_rule( | ||
'/datasets/files', | ||
'list_dataset_files', | ||
list_dataset_files_view, | ||
methods=['GET'] | ||
) | ||
|
||
app.add_url_rule( | ||
'/datasets/add', | ||
'add_dataset_file', | ||
add_file_to_dataset_view, | ||
methods=['GET'] | ||
) | ||
|
||
app.add_url_rule( | ||
'/datasets/create', | ||
'create_data', | ||
create_dataset_view, | ||
methods=['GET'] | ||
) | ||
|
||
|
||
app = create_app() | ||
|
||
if __name__ == '__main__': | ||
app.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright 2019 - Swiss Data Science Center (SDSC) | ||
# A partnership between École Polytechnique Fédérale de Lausanne (EPFL) and | ||
# Eidgenössische Technische Hochschule Zürich (ETHZ). | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Renku service management commands.""" |
Oops, something went wrong.