Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:

- name: Build the package with uv
run: |
uv pip install -e .
uv sync
uv build

- name: Publish the package to PyPI
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
*$py.class
*.so
.venv/
dist/
dist/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 jmzhang

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Snakemake Logger Plugin - Flowo

A Snakemake logger plugin that stores workflow execution data in PostgreSQL, making your workflow management more efficient and fun! 🎉
A Snakemake logger plugin designed to be used with **[FlowO](https://github.com/zhanghaomiao/flowo)** for real-time task monitoring, making workflow management simple, interactive, and fun! 🎉

**Demo page: [flowo online](https://zhanghaomiao.github.io/flowo)**

## 🎈 Features

Expand Down Expand Up @@ -31,16 +33,27 @@ The following environment variables are available for configuration in the `.env
- `POSTGRES_DB`: PostgreSQL database name (default: flowo_logs)
- `POSTGRES_HOST`: PostgreSQL host (default: localhost)
- `POSTGRES_PORT`: PostgreSQL port (default: localhost: 5432)
- `FLOWO_USER`:
- `FLOWO_WORKING_PATH`:
- `FLOWO_USER`: User displayed in Flowo
- `FLOWO_WORKING_PATH`: Snakemake execution project path

## 🚀 Usage

Basic usage
```bash
snakemake --logger flowo
snakemake --logger flowo
```
config `flowo_project_name` or `flowo_tags`
```
snakemake \
--config flowo_project_name=your_project_name flowo_tags="tagA,tagB,tagC" \
--logger flowo
```
or config in --configfile
```
flowo_project_name: your_project_name
flowo_tags: "tagA,tagB,tagC"
```

## 🙏 Acknowledgement

## 📜 License

MIT License
This project is developed based on the excellent work of [cademirch/snakemake-logger-plugin-snkmt](https://github.com/cademirch/snakemake-logger-plugin-snkmt).
Special thanks to the original author for providing a solid foundation under the MIT License.
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "snakemake-logger-plugin-flowo"
version = "0.1.2"
version = "0.1.8"
description = "A Snakemake logger plugin that stores workflow execution data in PostgreSQL"
readme = "README.md"
requires-python = ">=3.12"
Expand All @@ -26,6 +26,7 @@ dependencies = [
"psycopg2-binary>=2.9.9",
"pydantic>=2.11.5",
"pydantic-settings>=2.9.1",
"pygments>=2.19.2",
"snakemake>=9.6.2",
"snakemake-interface-logger-plugins>=1.2.3",
"sqlalchemy>=2.0.41",
Expand All @@ -38,9 +39,9 @@ flowo = "snakemake_logger_plugin_flowo:LogHandler"
flowo = "snakemake_logger_plugin_flowo.__main__:main"

[project.urls]
Homepage = "https://github.com/your-org/snakemake-logger-plugin-flowo"
Repository = "https://github.com/your-org/snakemake-logger-plugin-flowo"
Issues = "https://github.com/your-org/snakemake-logger-plugin-flowo/issues"
Homepage = "https://github.com/jmzhang1911/snakemake-logger-plugin-flowo"
Repository = "https://github.com/jmzhang1911/snakemake-logger-plugin-flowo"
Issues = "https://github.com/jmzhang1911/snakemake-logger-plugin-flowo/issues"

[tool.hatch.build.targets.wheel]
packages = ["snakemake_logger_plugin_flowo"]
Expand Down
4 changes: 3 additions & 1 deletion snakemake_logger_plugin_flowo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def __post_init__(self) -> None:
self.emit = lambda _: None
self.close = lambda: None
else:
logger.info("Plugin is successfully initialized and running. Monitoring ...")
logger.info(
"Plugin is successfully initialized and running. Monitoring ..."
)
self.flowo_path_valid()

self.log_file_path = Path(self.context.get("logfile"))
Expand Down
7 changes: 6 additions & 1 deletion snakemake_logger_plugin_flowo/event_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from . import parsers
from .models.enums import FileType, Status
from .models import File, Job, Rule, Error, Workflow
from .config import settings
from .config import logger, settings

"""
Context Dictionary Structure:
Expand Down Expand Up @@ -84,6 +84,7 @@ def handle(
workflow = session.query(Workflow).filter(Workflow.id == workflow_id).first()
if workflow and workflow.status == Status.RUNNING:
workflow.status = Status.ERROR
workflow.end_time = datetime.now()


class WorkflowStartedHandler(EventHandler):
Expand Down Expand Up @@ -182,6 +183,10 @@ def handle(
# session.add(job)
# session.flush()

# benchmark = job_data.benchmark
# if not isinstance(benchmark, list):
# benchmark = [benchmark]
# logger.info(benchmark)
self._add_files(job, job_data.input, FileType.INPUT, session)
self._add_files(job, job_data.output, FileType.OUTPUT, session)
self._add_files(job, job_data.log, FileType.LOG, session)
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7 changes: 5 additions & 2 deletions snakemake_logger_plugin_flowo/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Field, field_validator
from .config import logger


class Error(BaseModel):
Expand Down Expand Up @@ -72,7 +73,9 @@ def from_record(cls, record: LogRecord) -> "JobInfo":
for name, value in zip(record.resources._names, record.resources) # type: ignore
if name not in {"_cores", "_nodes"}
}

benchmark = getattr(record, "benchmark", None)
if benchmark and not isinstance(benchmark, list):
benchmark = [benchmark]
return cls(
jobid=getattr(record, "jobid", 0),
rule_name=getattr(record, "rule_name", ""),
Expand All @@ -85,7 +88,7 @@ def from_record(cls, record: LogRecord) -> "JobInfo":
input=getattr(record, "input", None),
log=getattr(record, "log", None),
output=getattr(record, "output", None),
benchmark=getattr(record, "benchmark", None),
benchmark=benchmark,
resources=resources,
)

Expand Down
Loading