Skip to content

Commit

Permalink
Merge pull request #433 from baobabsoluciones/development
Browse files Browse the repository at this point in the history
Feature/local dev (#432)
  • Loading branch information
ggsdc committed Mar 22, 2023
2 parents 6d2d6b8 + a63b846 commit c99629c
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 43 deletions.
2 changes: 1 addition & 1 deletion cornflow-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ENV DEBIAN_FRONTEND noninteractive
ENV TERM linux

# CORNFLOW vars
ARG CORNFLOW_VERSION=1.0.2
ARG CORNFLOW_VERSION=1.0.3

# install linux pkg
RUN apt update -y && apt-get install -y --no-install-recommends \
Expand Down
1 change: 0 additions & 1 deletion cornflow-server/cornflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
from .app import create_app
4 changes: 0 additions & 4 deletions cornflow-server/cornflow/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
"""
Main file with the creation of the app logic
"""
from gevent import monkey

monkey.patch_all()

# Full imports
import os
import click
Expand Down
5 changes: 3 additions & 2 deletions cornflow-server/cornflow/cli/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import click
import cornflow
from cornflow.app import create_app
from cornflow.commands import (
access_init_command,
create_user_with_role,
Expand Down Expand Up @@ -124,7 +125,7 @@ def init_cornflow_service():

if external_application == 0:
click.echo("Starting cornflow")
app = cornflow.create_app(environment, cornflow_db_conn)
app = create_app(environment, cornflow_db_conn)
with app.app_context():
path = f"{os.path.dirname(cornflow.__file__)}/migrations"
migrate = Migrate(app=app, db=db, directory=path)
Expand Down Expand Up @@ -156,7 +157,7 @@ def init_cornflow_service():

# execute gunicorn application
os.system(
"/usr/local/bin/gunicorn -c python:cornflow.gunicorn \"cornflow:create_app('$FLASK_ENV')\""
"/usr/local/bin/gunicorn -c python:cornflow.gunicorn \"cornflow.app:create_app('$FLASK_ENV')\""
)

elif external_application == 1:
Expand Down
2 changes: 1 addition & 1 deletion cornflow-server/cornflow/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def get_app():
warnings.filterwarnings("ignore")
external = int(os.getenv("EXTERNAL_APP", 0))
if external == 0:
from cornflow import create_app
from cornflow.app import create_app
else:
sys.path.append("./")
external_app = os.getenv("EXTERNAL_APP_MODULE", "external_app")
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ def create_new_case_payload(self, payload):
self.assertEqual(case["id"], response["id"])
self.assertEqual(case["name"], payload["name"])
self.assertEqual(case["description"], payload["description"])
case_data = self.client.raw.get_api_for_id("case", response["id"], "data").json()
case_data = self.client.raw.get_api_for_id(
"case", response["id"], "data"
).json()
self.assertEqual(case_data["data"], payload["data"])
return case

Expand Down Expand Up @@ -282,7 +284,8 @@ def test_get_all_schemas(self):
def test_get_one_schema(self):
response = self.client.raw.get_schema("solve_model_dag")
self.assertEqual(
{"error": "User does not have permission to access this dag"}, response.json()
{"error": "User does not have permission to access this dag"},
response.json(),
)


Expand Down
2 changes: 1 addition & 1 deletion cornflow-server/cornflow/tests/unit/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os

from click.testing import CliRunner
from cornflow import create_app
from cornflow.app import create_app
from cornflow.cli import cli
from cornflow.models import UserModel
from cornflow_core.models import (
Expand Down
1 change: 1 addition & 0 deletions cornflow-server/cornflow/tests/unit/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
register_views,
)


from cornflow.commands.dag import register_deployed_dags_command_test
from cornflow.endpoints import resources

Expand Down
4 changes: 0 additions & 4 deletions cornflow-server/cornflow/tests/unit/test_example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
from unittest.mock import patch


# Imports from environment
from cornflow_client import get_pulp_jsonschema, get_empty_schema

# Imports from internal modules
from cornflow.app import create_app
from cornflow.tests.const import EXAMPLE_URL, INSTANCE_PATH
from cornflow.tests.custom_test_case import CustomTestCase

Expand Down
2 changes: 1 addition & 1 deletion cornflow-server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setuptools.setup(
name="cornflow",
version="1.0.2",
version="1.0.3",
author="baobab soluciones",
author_email="cornflow@baobabsoluciones.es",
description="Cornflow is an open source multi-solver optimization server with a REST API built using flask.",
Expand Down

0 comments on commit c99629c

Please sign in to comment.