From bf9246634cb692f77963243c5cf627fb96974713 Mon Sep 17 00:00:00 2001 From: Luca Faggianelli Date: Mon, 22 May 2023 19:32:51 +0200 Subject: [PATCH 1/6] fix build output location --- frontend/package.json | 2 +- frontend/vite.config.ts | 2 +- src/plombery/_version.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index fd3d68bb..b54ff492 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "plombery", - "version": "0.3.0", + "version": "0.3.0-rc2", "description": "", "license": "MIT", "author": { diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index e5b2e67d..1e587777 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -11,6 +11,6 @@ export default defineConfig({ }, plugins: [react(), splitVendorChunkPlugin()], build: { - outDir: path.resolve('..', 'plombery', 'static'), + outDir: path.resolve('..', 'src', 'plombery', 'static'), }, }) diff --git a/src/plombery/_version.py b/src/plombery/_version.py index cc1cea4c..ce9c6638 100644 --- a/src/plombery/_version.py +++ b/src/plombery/_version.py @@ -1,3 +1,3 @@ # Keep it aligned with version in package.json -__version__ = "0.3.0" +__version__ = "0.3.0-rc2" From 7904909fb6ef7d2a1adb55f5c0aa167f338e4938 Mon Sep 17 00:00:00 2001 From: Luca Faggianelli Date: Tue, 6 Jun 2023 14:59:36 +0200 Subject: [PATCH 2/6] fix pipelines list component truncating long texts fix #120 --- frontend/src/components/ManualRunDialog.tsx | 2 +- frontend/src/components/PipelinesList.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/components/ManualRunDialog.tsx b/frontend/src/components/ManualRunDialog.tsx index 488da3d3..163cb1fd 100644 --- a/frontend/src/components/ManualRunDialog.tsx +++ b/frontend/src/components/ManualRunDialog.tsx @@ -195,7 +195,7 @@ const ManualRunDialog: React.FC = ({ pipeline }) => { icon={PlayIcon} onClick={() => setOpen(true)} > - Run pipeline + Run { {pipelines.map((pipeline) => ( -
- +
+ {pipeline.name} From 40466a2a91d33303ba98a4ec069cdd3d6df57bb7 Mon Sep 17 00:00:00 2001 From: Luca Faggianelli Date: Tue, 6 Jun 2023 15:17:20 +0200 Subject: [PATCH 3/6] improve pipeline title on small screens --- frontend/src/pages/pipelines/[pipelineId]/index.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/pipelines/[pipelineId]/index.tsx b/frontend/src/pages/pipelines/[pipelineId]/index.tsx index 03799124..4f5cc08d 100644 --- a/frontend/src/pages/pipelines/[pipelineId]/index.tsx +++ b/frontend/src/pages/pipelines/[pipelineId]/index.tsx @@ -55,11 +55,12 @@ const PipelineView: React.FC = () => { header={
- + Pipeline {pipeline.name} {pipeline.description && ( - · {pipeline.description} + · + {pipeline.description} )} From 05bc02ab3ac46e7787c6cc29b7503e259dc75049 Mon Sep 17 00:00:00 2001 From: Luca Faggianelli Date: Tue, 6 Jun 2023 15:41:14 +0200 Subject: [PATCH 4/6] improve page header responsivity --- frontend/src/components/Breadcrumbs.tsx | 84 ++++++++++--------- frontend/src/components/PageLayout.tsx | 2 +- .../pages/pipelines/[pipelineId]/index.tsx | 21 +++-- .../triggers/[triggerId]/index.tsx | 28 +++++-- 4 files changed, 76 insertions(+), 59 deletions(-) diff --git a/frontend/src/components/Breadcrumbs.tsx b/frontend/src/components/Breadcrumbs.tsx index 3dffc8fa..6af4d1d7 100644 --- a/frontend/src/components/Breadcrumbs.tsx +++ b/frontend/src/components/Breadcrumbs.tsx @@ -8,57 +8,61 @@ interface Props { pipeline: Pipeline trigger?: Trigger run?: PipelineRun + className?: string } const Separator = () => / -const Breadcrumbs: React.FC = ({ pipeline, trigger, run }) => { +const Breadcrumbs: React.FC = ({ + pipeline, + trigger, + run, + className, +}) => { if (run && !trigger) { throw new Error() } return ( -
- - - Pipelines - - - - {trigger ? ( - {pipeline.name} - ) : ( - pipeline.name - )} - - - {trigger && ( - <> - - Triggers - - - {run ? ( - - {trigger.name} - - ) : ( - trigger.name - )} - - + + + Pipelines + + + + {trigger ? ( + {pipeline.name} + ) : ( + pipeline.name )} + - {run && trigger && ( - <> - - Runs - - #{run.id} - - )} - -
+ {trigger && ( + <> + + Triggers + + + {run ? ( + + {trigger.name} + + ) : ( + trigger.name + )} + + + )} + + {run && trigger && ( + <> + + Runs + + #{run.id} + + )} +
) } diff --git a/frontend/src/components/PageLayout.tsx b/frontend/src/components/PageLayout.tsx index d01451be..1df72eb8 100644 --- a/frontend/src/components/PageLayout.tsx +++ b/frontend/src/components/PageLayout.tsx @@ -14,7 +14,7 @@ const PageLayout: React.FC = ({ children, header }) => { return (
- {header &&
{header}
} + {header &&
{header}
} {isAuthenticated && isAuthenticationEnabled && }
diff --git a/frontend/src/pages/pipelines/[pipelineId]/index.tsx b/frontend/src/pages/pipelines/[pipelineId]/index.tsx index 4f5cc08d..ae4f6260 100644 --- a/frontend/src/pages/pipelines/[pipelineId]/index.tsx +++ b/frontend/src/pages/pipelines/[pipelineId]/index.tsx @@ -53,22 +53,25 @@ const PipelineView: React.FC = () => { return ( -
- - Pipeline {pipeline.name} +
+ + + + Pipeline {pipeline.name} + {pipeline.description && ( - + · {pipeline.description} )} - -
- -
+ + + + +
} > diff --git a/frontend/src/pages/pipelines/[pipelineId]/triggers/[triggerId]/index.tsx b/frontend/src/pages/pipelines/[pipelineId]/triggers/[triggerId]/index.tsx index 47ebd91e..25076fa0 100644 --- a/frontend/src/pages/pipelines/[pipelineId]/triggers/[triggerId]/index.tsx +++ b/frontend/src/pages/pipelines/[pipelineId]/triggers/[triggerId]/index.tsx @@ -79,26 +79,36 @@ const TriggerView: React.FC = () => { ) return ( -
- Trigger {trigger.name} - -
- - {runTriggerButton} - +
+ + + Trigger {trigger.name} + {trigger.description && ( + + · + {trigger.description} + + )} + + + {runTriggerButton} + + + +
} > From ee1f68bec101c46c72684e5e7db5fcefade8fedb Mon Sep 17 00:00:00 2001 From: Luca Faggianelli Date: Wed, 7 Jun 2023 00:29:11 +0200 Subject: [PATCH 5/6] start scheduler in fastapi startup callback --- README.md | 10 ++++++++-- examples/requirements.txt | 3 +++ examples/run.ps1 | 2 +- examples/run.sh | 2 +- examples/src/app.py | 2 +- src/plombery/__init__.py | 21 +++++++++++++++------ src/plombery/orchestrator/__init__.py | 3 ++- 7 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 examples/requirements.txt diff --git a/README.md b/README.md index 93c5922e..a71cb8d2 100644 --- a/README.md +++ b/README.md @@ -139,8 +139,14 @@ pip install -r requirements-dev.txt for development purposes, it's useful to run the example application: ```sh cd examples/ -export PYTHONPATH=$(pwd)/.. -uvicorn dummy.app:app --reload --reload-dir .. + +# Create a venv for the example app +python -m venv .venv +source .venv/bin/activate +pip install -r requirements + +./run.sh +# or ./run.ps1 on windows ``` The React frontend is in the `frontend/` folder, enter the folder diff --git a/examples/requirements.txt b/examples/requirements.txt new file mode 100644 index 00000000..33889f63 --- /dev/null +++ b/examples/requirements.txt @@ -0,0 +1,3 @@ +-e .. +python-dateutil +pandas \ No newline at end of file diff --git a/examples/run.ps1 b/examples/run.ps1 index 3132246c..5d492f92 100644 --- a/examples/run.ps1 +++ b/examples/run.ps1 @@ -1,2 +1,2 @@ -$env:PYTHONPATH="$(pwd)/.." +$env:PYTHONPATH="$(pwd)" python src/app.py \ No newline at end of file diff --git a/examples/run.sh b/examples/run.sh index 852087e7..c0db7aa9 100755 --- a/examples/run.sh +++ b/examples/run.sh @@ -1,2 +1,2 @@ -export PYTHONPATH=$(pwd)/.. +export PYTHONPATH=$(pwd) python src/app.py \ No newline at end of file diff --git a/examples/src/app.py b/examples/src/app.py index 930fdd45..1cdb7e3c 100644 --- a/examples/src/app.py +++ b/examples/src/app.py @@ -4,7 +4,7 @@ from plombery import get_app # noqa: F401 -from examples.src import sales_pipeline, sync_pipeline # noqa: F401 +from src import sales_pipeline, sync_pipeline # noqa: F401 if __name__ == "__main__": diff --git a/src/plombery/__init__.py b/src/plombery/__init__.py index 637af9b4..13407d8b 100644 --- a/src/plombery/__init__.py +++ b/src/plombery/__init__.py @@ -1,5 +1,6 @@ -import logging from typing import List, Type +import logging +import os from apscheduler.schedulers.base import SchedulerAlreadyRunningError from pydantic import BaseModel @@ -20,15 +21,15 @@ _logger.addHandler(logging.StreamHandler()) +if os.getenv("DEBUG_APS"): + logging.basicConfig() + logging.getLogger("apscheduler").setLevel(logging.DEBUG) + + class _Plombery: def __init__(self) -> None: self._apply_settings() - try: - orchestrator.start() - except SchedulerAlreadyRunningError: - pass - def _apply_settings(self): for notification in settings.notifications or []: self.add_notification_rule(notification) @@ -51,6 +52,14 @@ async def __call__(self, scope, receive, send): _app = _Plombery() +@app.on_event("startup") +def on_fastapi_start(): + try: + orchestrator.start() + except SchedulerAlreadyRunningError: + pass + + def get_app(): return _app diff --git a/src/plombery/orchestrator/__init__.py b/src/plombery/orchestrator/__init__.py index dba4b2c8..24d2dd8e 100644 --- a/src/plombery/orchestrator/__init__.py +++ b/src/plombery/orchestrator/__init__.py @@ -1,5 +1,5 @@ -from datetime import datetime, timedelta from typing import Any, Dict, Tuple +from datetime import datetime, timedelta from apscheduler.executors.asyncio import AsyncIOExecutor from apscheduler.job import Job @@ -37,6 +37,7 @@ def register_pipeline(self, pipeline: Pipeline): self.scheduler.add_job( id=job_id, + name=job_id, func=run, trigger=trigger.schedule, kwargs=dict(pipeline=pipeline, trigger=trigger), From 43efde3bde69275efc19f2b075c0c2b456ffa080 Mon Sep 17 00:00:00 2001 From: Luca Faggianelli Date: Wed, 7 Jun 2023 00:32:19 +0200 Subject: [PATCH 6/6] bump version --- frontend/package.json | 2 +- src/plombery/_version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index b54ff492..fd3d68bb 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "plombery", - "version": "0.3.0-rc2", + "version": "0.3.0", "description": "", "license": "MIT", "author": { diff --git a/src/plombery/_version.py b/src/plombery/_version.py index ce9c6638..cc1cea4c 100644 --- a/src/plombery/_version.py +++ b/src/plombery/_version.py @@ -1,3 +1,3 @@ # Keep it aligned with version in package.json -__version__ = "0.3.0-rc2" +__version__ = "0.3.0"