-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* TLC - Remove TYPE_CHECKING code - Improve type checking * Add translation code and product validation task This adds a translations endpoint that is used to get translations for the workflow specific stuff. This also adds a task and schedule to do sanity checks on the database * Bump version: 0.0.9 → 0.0.10 * Fix import sorting
- Loading branch information
Showing
24 changed files
with
455 additions
and
46 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 |
---|---|---|
|
@@ -127,3 +127,5 @@ dmypy.json | |
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
.vscode |
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,32 @@ | ||
# Copyright 2019-2020 SURF. | ||
# 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. | ||
|
||
from typing import Dict | ||
|
||
import structlog | ||
from fastapi import Query | ||
from fastapi.routing import APIRouter | ||
|
||
from orchestrator.services.translations import generate_translations | ||
|
||
logger = structlog.get_logger(__name__) | ||
|
||
|
||
router = APIRouter() | ||
|
||
|
||
@router.get("/{language}", response_model=dict) | ||
def get_translations(language: str = Query(..., regex="^[a-z]+-[A-Z]+$")) -> Dict[str, str]: | ||
translations = generate_translations(language) | ||
|
||
return translations |
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
def upgrade() -> None: | ||
conn = op.get_bind() | ||
conn.execute( | ||
""" | ||
|
38 changes: 38 additions & 0 deletions
38
...estrator/migrations/versions/schema/2021-04-06_3c8b9185c221_add_validate_products_task.py
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,38 @@ | ||
"""Add task_validate_products. | ||
Revision ID: 3c8b9185c221 | ||
Revises: 3323bcb934e7 | ||
Create Date: 2020-04-06 09:17:49.395612 | ||
""" | ||
from uuid import uuid4 | ||
|
||
import sqlalchemy as sa | ||
from alembic import op | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = "3c8b9185c221" | ||
down_revision = "3323bcb934e7" | ||
branch_labels = None | ||
depends_on = None | ||
|
||
workflows = [ | ||
{"name": "task_validate_products", "description": "Validate products", "workflow_id": uuid4(), "target": "SYSTEM"}, | ||
] | ||
|
||
|
||
def upgrade() -> None: | ||
conn = op.get_bind() | ||
for workflow in workflows: | ||
conn.execute( | ||
sa.text( | ||
"INSERT INTO workflows VALUES (:workflow_id, :name, :target, :description, now()) ON CONFLICT DO NOTHING" | ||
), | ||
**workflow, | ||
) | ||
|
||
|
||
def downgrade() -> None: | ||
conn = op.get_bind() | ||
for workflow in workflows: | ||
conn.execute(sa.text("DELETE FROM workflows WHERE name = :name"), {"name": workflow["name"]}) |
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,25 @@ | ||
# Copyright 2019-2020 SURF. | ||
# 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. | ||
|
||
|
||
from orchestrator.db.models import ProcessTable | ||
from orchestrator.schedules.scheduling import scheduler | ||
from orchestrator.services.processes import start_process | ||
|
||
|
||
@scheduler(name="Validate Products and inactive subscriptions", time_unit="day", at="02:30") | ||
def validate_products() -> None: | ||
if not ProcessTable.query.filter( | ||
ProcessTable.workflow == "validate_products", ProcessTable.last_status != "completed" | ||
).count(): | ||
start_process("validate_products") |
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
Oops, something went wrong.