Skip to content
Closed
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
19 changes: 8 additions & 11 deletions .github/workflows/ci.yml → .github/workflows/postgres.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
name: ci
name: postgres

on:
pull_request:
branches:
- main
- test
workflow_dispatch:

jobs:
test:
name: CI on python${{ matrix.python }} via ${{ matrix.os }}
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- os: ubuntu-22.04
python: "3.10"
- os: ubuntu-22.04
python: "3.11"
- os: ubuntu-24.04
python: "3.12"
- python: "3.10"
- python: "3.13"
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install tox
run: pip install tox
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Install postgresql
run: |
sudo apt-get install -y postgresql
Expand All @@ -41,3 +36,5 @@ jobs:
pg_isready
- name: Run unit tests
run: tox -e py3
- name: Run tox
run: uv tool run tox -e postgresql
27 changes: 27 additions & 0 deletions .github/workflows/sqlite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: sqlite

on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
test:
name: CI on python${{ matrix.python }} via ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- python: "3.10"
- python: "3.13"
steps:
- uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: Install uv
uses: astral-sh/setup-uv@v5
- name: Run tox
run: uv tool run tox
48 changes: 48 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
[project]
name = "shaman"
authors = [
{name = "Alfredo Deza"},
{name = "Kyr Shatskyy", email = "kyrylo.shatskyy@clyso.com"},
]
version = "0.1"
description = ""
readme = "README.rst"
license = {text = "MIT"}
requires-python = ">=3.10"
dependencies = [
"pecan",
"sqlalchemy==1.4.53",
"psycopg2-binary==2.9.10",
"pecan-notario",
"requests",
"jinja2",
"pika",
]
classifiers = [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Topic :: Utilities',
'Operating System :: POSIX',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
]

[project.entry-points."pecan.command"]
populate = "shaman.commands.populate:PopulateCommand"

[project.optional-dependencies]
test = [
"pytest",
"mock",
"webtest",
]

[build-system]
build-backend = "setuptools.build_meta"
requires = [
"setuptools>=45",
"wheel",
]

[tool.setuptools.packages.find]
271 changes: 260 additions & 11 deletions requirements.txt

Large diffs are not rendered by default.

45 changes: 0 additions & 45 deletions setup.py

This file was deleted.

9 changes: 9 additions & 0 deletions shaman/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from sqlalchemy import create_engine, MetaData, event
from sqlalchemy.orm import scoped_session, sessionmaker, object_session, mapper
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.pool import Pool
from pecan import conf


Expand Down Expand Up @@ -116,6 +117,8 @@ def init_model():
"""
conf.sqlalchemy_w.engine = _engine_from_config(conf.sqlalchemy_w)
conf.sqlalchemy_ro.engine = _engine_from_config(conf.sqlalchemy_ro)
if 'sqlite' in dict(conf)['sqlalchemy_w']['url']:
event.listen(Pool, 'connect', sqlite_connect, named=True)


def _engine_from_config(configuration):
Expand All @@ -124,6 +127,12 @@ def _engine_from_config(configuration):
return create_engine(url, **configuration)


def sqlite_connect(**kw):
dbapi_con = kw['dbapi_connection']
dbapi_con.execute('PRAGMA journal_mode=MEMORY')
dbapi_con.execute('PRAGMA synchronous=OFF')


def start():
Session.bind = conf.sqlalchemy_w.engine
metadata.bind = conf.sqlalchemy_w.engine
Expand Down
2 changes: 1 addition & 1 deletion shaman/templates/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

def last_seen(date_object):
now = datetime.now(timezone.utc)
difference = now - date_object
difference = now - date_object.astimezone(timezone.utc)
formatted = ReadableSeconds(difference.seconds, days=difference.days)
return "%s ago" % formatted

Expand Down
Loading