Skip to content

Commit

Permalink
Merge pull request #484 from baobabsoluciones/release/v1.0.8
Browse files Browse the repository at this point in the history
Release/v1.0.8
  • Loading branch information
ggsdc authored Oct 20, 2023
2 parents a059456 + 2dd5751 commit 5ba402b
Show file tree
Hide file tree
Showing 86 changed files with 9,323 additions and 6,783 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test_cornflow_client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
types: [ opened, edited, synchronize, reopened ]
paths:
- 'libs/client/**'
- '.github/workflows/test_cornflow_client.yml'
- '!libs/client/README.rst'
- '!libs/client/setup.py'
push:
Expand Down Expand Up @@ -57,7 +58,7 @@ jobs:
strategy:
max-parallel: 21
matrix:
python-version: [ 3.8, 3.9, '3.10', '3.11' ]
python-version: [3.8, 3.9, '3.10', '3.11']
os: [ ubuntu-latest ]

steps:
Expand All @@ -84,7 +85,7 @@ jobs:
cd cornflow-server
python -m venv afvenv
source afvenv/bin/activate
AIRFLOW_VERSION=2.2.1
AIRFLOW_VERSION=2.7.1
PYTHON_VERSION="$(python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
CLIENT_BRANCH="${{ github.head_ref || github.ref_name }}"
CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/test_cornflow_dags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
types: [ opened, edited, synchronize, reopened ]
paths:
- 'cornflow-dags/**'
- '.github/workflows/test_cornflow_dags.yml'
- '!cornflow-dags/README.rst'
push:
branches:
Expand All @@ -25,7 +26,7 @@ jobs:
strategy:
max-parallel: 21
matrix:
python-version: [3.7, 3.8]
python-version: [3.8, 3.9, '3.10', '3.11']
os: [ubuntu-latest]

steps:
Expand All @@ -46,12 +47,12 @@ jobs:
python -m pip install -U "git+https://github.com/baobabsoluciones/cornflow@${CLIENT_BRANCH}#subdirectory=libs/client"
- name: Install airflow
run: |
AIRFLOW_VERSION=2.1.0
AIRFLOW_VERSION=2.7.1
PYTHON_VERSION="$(python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
CLIENT_BRANCH="${{ github.head_ref || github.ref_name }}"
CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
pip install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"
python -m pip uninstall cornflow-client -y
python -m pip install "apache-airflow==${AIRFLOW_VERSION}" --constraint "${CONSTRAINT_URL}"
python -m pip install -U orloge pulp
python -m pip install -U "git+https://github.com/baobabsoluciones/cornflow@${CLIENT_BRANCH}#subdirectory=libs/client"
airflow db init
airflow users create \
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test_cornflow_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
types: [ opened, edited, synchronize, reopened ]
paths:
- 'cornflow-server/**'
- '.github/workflows/test_cornflow_server.yml'
- '!cornflow-server/docs/**'
- '!cornflow-server/README.rst'
push:
Expand All @@ -27,7 +28,7 @@ jobs:
strategy:
max-parallel: 21
matrix:
python-version: [3.8]
python-version: [3.8, 3.9, '3.10', '3.11']
os: [ubuntu-latest]

services:
Expand Down Expand Up @@ -71,7 +72,7 @@ jobs:
run: |
python -m venv afvenv
source afvenv/bin/activate
AIRFLOW_VERSION=2.2.1
AIRFLOW_VERSION=2.7.1
PYTHON_VERSION="$(python3 --version | cut -d " " -f 2 | cut -d "." -f 1-2)"
CLIENT_BRANCH="${{ github.head_ref || github.ref_name }}"
CONSTRAINT_URL="https://raw.githubusercontent.com/apache/airflow/constraints-${AIRFLOW_VERSION}/constraints-${PYTHON_VERSION}.txt"
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,7 @@ cornssh.pub
*.db

# IO files
*.mps
*.mps

# airflow logs
cornflow-server/airflow_config/logs
18 changes: 6 additions & 12 deletions QUICK_START_GUIDE.RST
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,6 @@ If on Windows export should be changed to set.
.. raw:: html

</details>


..
Docker
------

You will also need to install `Docker Community Edition <https://docs.docker.com/engine/install/>`_ and `Docker Compose <https://docs.docker.com/compose/install/>`_. See `here <https://baobabsoluciones.github.io/cornflow/deploy/index.html>`_ how to deploy your own cornflow server.


For cornflow-app
Expand Down Expand Up @@ -192,10 +184,10 @@ If it is the first time you use cornflow-server, you will then need to setup cor
export FLASK_APP=cornflow.app
export DATABASE_URL=sqlite:///cornflow.db
python manage.py db upgrade
python manage.py access_init
python manage.py create_service_user --username=airflow [email protected] --password=airflow_test_password
python manage.py create_admin_user --username=cornflow [email protected] --password=cornflow_admin_password
flask db upgrade
flask access_init
flask create_service_user --username=airflow [email protected] --password=airflow_test_password
flask create_admin_user --username=cornflow [email protected] --password=cornflow_admin_password
From there, you can launch cornflow-server by navigating to the cornflow-server repository and running:

Expand Down Expand Up @@ -243,7 +235,9 @@ To do so, you need to clone the repository and create a new folder with the name
- :code:`/schemas`

- :code:`instance.json`: jsonschema that describes the input data.
- :code:`instance_checks.json`: jsonschema that describes the output of the instance checks.
- :code:`solution.json`: jsonschema that describes the output data.
- :code:`solution_checks.json`: jsonschema that describes the output of the solution checks.
- :code:`config.json` (optional): jsonschema that describes the configuration.

- :code:`/solvers`
Expand Down
16 changes: 13 additions & 3 deletions cornflow-dags/DAG/activate_dags.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import cornflow_client.airflow.dag_utilities as utils
from airflow import DAG
from airflow.operators.python import PythonOperator
from airflow.secrets.environment_variables import EnvironmentVariablesBackend
import cornflow_client.airflow.dag_utilities as utils

from update_all_schemas import get_new_apps
from airflow.operators.python import PythonOperator


def create_dag(app):
Expand All @@ -27,7 +28,16 @@ def solve(**kwargs):
**kwargs
)
with dag:
t1 = PythonOperator(task_id=app.name, python_callable=solve)
notify = getattr(app, "notify", True)
if not notify:
t1 = PythonOperator(task_id=app.name, python_callable=solve)
else:
t1 = PythonOperator(
task_id=app.name,
python_callable=solve,
on_failure_callback=utils.callback_email,
)

return dag


Expand Down
10 changes: 0 additions & 10 deletions cornflow-dags/DAG/bar_cutting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ class BarCutting(ApplicationCore):
solution = Solution
solvers = dict(mip=MipModel, CG=ColumnGeneration)
schema = load_json(os.path.join(os.path.dirname(__file__), "./schemas/config.json"))
schema["properties"]["solver"]["enum"].append("mip.cbc")
schema["properties"]["solver"]["enum"].append("CG.cbc")

@property
def test_cases(self) -> List[Union[Dict, Tuple[Dict, Dict]]]:

options_instance = ["data/example_instance_1.json"]

options_solution = ["data/example_solution_1.json"]
Expand All @@ -44,10 +41,3 @@ def test_cases(self) -> List[Union[Dict, Tuple[Dict, Dict]]]:
)
for i in range(len(options_instance))
]

def get_solver(self, name: str = "mip") -> Union[Type[Experiment], None]:
if "." in name:
solver, _ = name.split(".")
else:
solver = name
return self.solvers.get(solver)
4 changes: 2 additions & 2 deletions cornflow-dags/DAG/bar_cutting/schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"properties": {
"solver": {
"type": "string",
"enum": ["mip", "CG"],
"default": "mip"
"enum": ["mip", "CG", "mip.cbc", "CG.cbc"],
"default": "mip.cbc"
},
"timeLimit": {
"type": "number"
Expand Down
12 changes: 1 addition & 11 deletions cornflow-dags/DAG/facility_location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,7 @@ class FacilityLocation(ApplicationCore):
instance = Instance
solution = Solution
solvers = dict(Pyomo=PyomoSolver)
schema = get_empty_schema(
properties=dict(timeLimit=dict(type="number")),
solvers=list(solvers.keys()) + ["Pyomo.cbc"],
)

def get_solver(self, name: str = "Pyomo") -> Union[Type[Experiment], None]:
if "." in name:
solver, _ = name.split(".")
else:
solver = name
return self.solvers.get(solver)
schema = load_json(os.path.join(os.path.dirname(__file__), "./schemas/config.json"))

@property
def test_cases(self):
Expand Down
14 changes: 14 additions & 0 deletions cornflow-dags/DAG/facility_location/schemas/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"solver": {
"type": "string",
"enum": ["Pyomo", "Pyomo.cbc"],
"default": "Pyomo.cbc"
},
"timeLimit": {
"type": "number"
}
}
}
28 changes: 21 additions & 7 deletions cornflow-dags/DAG/rostering/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ This decision is subject to:
- RQ12: employees can not work during downtime.
- RQ13: employee starting hour preference.
- RQ14: employee max preference hours.
- RQ15: employee weekly schedule
- RQ16: fixed worktable

Parameters
----------
Expand All @@ -38,6 +40,8 @@ Parameters
- Employee preferences: starting and number of hours preferences for one day.
- Weekly schedule: starting and ending hours for each week day.
- Schedule exceptions: starting and ending hours for a specific date.
- Employee schedule: days of the week the employee can work on
- Fixed worktable: worktable fixed by the user

- Parameters:

Expand All @@ -47,11 +51,21 @@ Parameters
- Minimum working hours: the minimum amount of hours that have to be worked each day that the employee works.
- Slot length: the length of each time slot in minutes.

- Requirements: table indicating which requirements should be complied and which not
- Requirements: table indicating which requirements should be complied and which not, and if they are, if they should be applied as strict or soft constraints.

- rq09: true or false if the skills requirement has to be applied
- rq10: true or false if the employee holidays requirement has to be applied
- rq11: true or false if the store holidays requirement has to be applied
- rq12: true or false if the employee downtime requirement has to be applied
- rq13: true or false if the employee preferences requirement has to be applied
- rq14: true or false if the employee max preference hours requirement has to be applied
- rq02: "soft", "strict" or "deactivated for the weekly hours constraint
- rq03: "soft", "strict" or "deactivated for the maximum daily hours constraint
- rq05: "soft", "strict" or "deactivated for the maximum days worked per week constraint
- rq06: "soft", "strict" or "deactivated for the minimum daily hours constraint
- rq07: "soft", "strict" or "deactivated for the minimum rest hours between shifts constraint
- rq08: "soft", "strict" or "deactivated for the constraint about needing to have a manager in the store at all times
- rq09: "soft", "strict" or "deactivated for the skills constraint
- rq10: "soft", "strict" or "deactivated for the employees' holidays constraint
- rq11: "strict" or "deactivated for the store holidays constraint
- rq12: "strict" or "deactivated for the employee downtime constraint
- rq13: "soft", "strict" or "deactivated for the employee start hour preferences constraint
- rq14: "soft", "strict" or "deactivated for the employee max preference hours constraint
- rq15: "soft", "strict" or "deactivated for the employee schedule constraint
- rq16: "soft", "strict" or "deactivated for the fixed worktable constraint

- Penalties: table indicating for each soft constraint the penalty level when it is not respected.
14 changes: 9 additions & 5 deletions cornflow-dags/DAG/rostering/core/const.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
INSTANCE_KEYS_RELATION = {
("employees", "id"): [
("contracts", "id_employee"),
("skills_employees", "id_employee"),
("contracts", "id_employee", True),
("skills_employees", "id_employee", False),
("employee_holidays", "id_employee", False),
("employee_downtime", "id_employee", False),
("employee_preferences", "id_employee", False),
("employee_schedule", "id_employee", False),
],
("shifts", "id"): [("contracts", "id_shift")],
("shifts", "id"): [("contracts", "id_shift", False)],
("skills", "id"): [
("skills_employees", "id_skill"),
("skill_demand", "id_skill"),
("skills_employees", "id_skill", False),
("skill_demand", "id_skill", False),
],
}
Loading

0 comments on commit 5ba402b

Please sign in to comment.