-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Workflows + Pypi - JsonStorage - Improved logging
- Loading branch information
Showing
9 changed files
with
259 additions
and
52 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Lint, Typecheck, and Test | ||
|
||
on: | ||
push: | ||
branches: [ main, dev ] | ||
pull_request: | ||
branches: [ main, dev ] | ||
|
||
jobs: | ||
ci: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.9", "3.10", "3.11"] | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Setup Poetry | ||
uses: abatilo/actions-poetry@v2 | ||
|
||
- name: Configure local .venv | ||
run: | | ||
poetry config virtualenvs.create true --local | ||
poetry config virtualenvs.in-project true --local | ||
- uses: actions/cache@v3 | ||
name: Cache Dependencies | ||
with: | ||
path: ./.venv | ||
key: venv-${{ hashFiles('poetry.lock') }} | ||
|
||
- name: Install dependencies | ||
run: poetry install | ||
|
||
- name: Linting | ||
run: poetry run ruff -v marque/ | ||
|
||
- name: Typecheck | ||
run: poetry run mypy -v marque/ | ||
|
||
- name: Tests | ||
run: poetry run pytest -v |
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,45 @@ | ||
name: Build and Publish | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
jobs: | ||
build-and-publish: | ||
environment: protected | ||
permissions: | ||
contents: read | ||
id-token: write | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Setup Poetry | ||
uses: abatilo/actions-poetry@v2 | ||
|
||
- name: Configure local .venv | ||
run: | | ||
poetry config virtualenvs.create true --local | ||
poetry config virtualenvs.in-project true --local | ||
- uses: actions/cache@v3 | ||
name: Cache Dependencies | ||
with: | ||
path: ./.venv | ||
key: venv-${{ hashFiles('poetry.lock') }} | ||
|
||
- name: Install dependencies | ||
run: poetry install | ||
|
||
- name: Build package | ||
run: poetry build | ||
|
||
- name: Publish to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |
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 |
---|---|---|
@@ -1,5 +1,10 @@ | ||
from marque.flow import Flow | ||
from marque.helpers import repeat | ||
from marque.scope import Scope | ||
from marque.storage import JsonStorage, MemoryStorage, PolarsStorage | ||
|
||
__all__ = ["Flow", "Scope", "repeat"] | ||
__all__ = ["Flow", "Scope", "repeat", "MemoryStorage", "PolarsStorage", "JsonStorage"] | ||
|
||
from loguru import logger | ||
|
||
logger.disable("marque") |
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,47 @@ | ||
import pathlib | ||
import sys | ||
import typing as t | ||
|
||
from loguru import logger | ||
|
||
g_configured: bool = False | ||
|
||
LogLevelList = ["trace", "debug", "info", "success", "warning", "error", "critical"] | ||
LogLevelLiteral = t.Literal["trace", "debug", "info", "success", "warning", "error", "critical"] | ||
|
||
|
||
def configure_logging( | ||
log_level: str, | ||
log_file: pathlib.Path | None = None, | ||
log_file_level: LogLevelLiteral = "debug", | ||
) -> None: | ||
global g_configured | ||
|
||
if g_configured: | ||
return | ||
|
||
logger.enable("marque") | ||
|
||
logger.level("TRACE", color="<magenta>", icon="[T]") | ||
logger.level("DEBUG", color="<blue>", icon="[_]") | ||
logger.level("INFO", color="<cyan>", icon="[=]") | ||
logger.level("SUCCESS", color="<green>", icon="[+]") | ||
logger.level("WARNING", color="<yellow>", icon="[-]") | ||
logger.level("ERROR", color="<red>", icon="[!]") | ||
logger.level("CRITICAL", color="<RED>", icon="[x]") | ||
|
||
# Default format: | ||
# "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | " | ||
# "<level>{level: <8}</level> | " | ||
# "<cyan>{name}</cyan>:<cyan>{function}</cyan>:<cyan>{line}</cyan> - <level>{message}</level>", | ||
|
||
custom_format = "<green>{time:HH:mm:ss.SSS}</green> | <level>{level.icon}</level> {message}" | ||
|
||
logger.remove() | ||
logger.add(sys.stderr, format=custom_format, level=log_level.upper()) | ||
|
||
if log_file is not None: | ||
logger.add(log_file, format=custom_format, level=log_file_level.upper()) | ||
logger.info(f"Logging to {log_file}") | ||
|
||
g_configured = True |
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
Oops, something went wrong.