Skip to content

Commit a7f51c4

Browse files
authored
use connection instead of service/cursor (#41)
* use connection instead of service/cursor * fix tests * more fixes * drop psycopg2 support * fix workflow * named args * more * fix * more fixes * improve readability * fix arg name * fix * update test+ * fix test
1 parent 38d2865 commit a7f51c4

17 files changed

+310
-344
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: 🚀 Deploying to pypi
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
workflow_dispatch:
8+
workflow_call:
9+
10+
jobs:
11+
build-python-wheel:
12+
name: "🐍 Python Wheel"
13+
uses: ./.github/workflows/wheel.yml
14+
secrets: inherit
15+
16+
release-pypi:
17+
name: "🐍 Release on PyPI"
18+
runs-on: ubuntu-latest
19+
needs: [build-python-wheel]
20+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
21+
environment:
22+
name: pypi
23+
url: https://pypi.org/p/${{ github.event.repository.name }}
24+
permissions:
25+
id-token: write
26+
contents: write
27+
28+
steps:
29+
- name: Retrieve artifact from Python build
30+
uses: actions/download-artifact@v4
31+
with:
32+
name: python_wheel
33+
path: dist/
34+
35+
- name: upload release asset
36+
env:
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: gh release upload --repo ${{ github.repository_owner }}/${{ github.event.repository.name }} ${{ github.ref_name }} "dist/${{ github.event.repository.name }}-${{ github.ref_name }}.tar.gz"
39+
40+
- name: Deploy to PyPI
41+
uses: pypa/gh-action-pypi-publish@release/v1

.github/workflows/release.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

.github/workflows/test.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ jobs:
1717

1818
strategy:
1919
matrix:
20-
psycopg-version: [2, 3]
2120
pg-version: [12, 13, 14, 15, 16]
2221
fail-fast: true
2322

@@ -60,10 +59,9 @@ jobs:
6059
run: |
6160
pip install -r requirements.txt
6261
pip install -r requirements-test.txt
63-
pip install -r requirements-psycopg${{ matrix.psycopg-version }}.txt
6462
6563
- name: Install pirogue
66-
run: python -m pip install -e .[psycopg${{ matrix.psycopg-version }}]
64+
run: python -m pip install -e .
6765

6866
- name: Setup tests
6967
run: |

.github/workflows/wheel.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ jobs:
3434
run: python -m pip install -e .
3535

3636
- name: Build a binary wheel and a source tarball
37-
run: >-
38-
python -m build --sdist --wheel --outdir dist/ .
37+
run: python -m build .
3938

4039
- uses: actions/upload-artifact@v4
4140
with:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ repos:
3939

4040
# tool to automatically upgrade syntax for newer versions of the language
4141
- repo: https://github.com/asottile/pyupgrade
42-
rev: v3.19.1
42+
rev: v3.20.0
4343
hooks:
4444
- id: pyupgrade
4545
args: [--py310-plus]

pirogue/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import argparse
44
import os
55

6+
import psycopg
67
import yaml
78

89
from pirogue.multiple_inheritance import MultipleInheritance
@@ -97,11 +98,13 @@ def main():
9798
else:
9899
pg_service = os.getenv("PGSERVICE")
99100

101+
conn = psycopg.connect(f"service={pg_service}")
102+
100103
if args.command == "single_inheritance":
101104
success = SingleInheritance(
102105
parent_table=args.parent_table,
103106
child_table=args.child_table,
104-
pg_service=pg_service,
107+
connection=conn,
105108
view_schema=args.view_schema,
106109
view_name=args.view_name,
107110
pkey_default_value=args.pkey_default_value,
@@ -123,12 +126,12 @@ def main():
123126
yaml_definition,
124127
variables=variables,
125128
create_joins=args.create_joins,
126-
pg_service=pg_service,
129+
connection=conn,
127130
).create()
128131

129132
elif args.command == "simple_joins":
130133
yaml_definition = yaml.safe_load(args.definition_file)
131-
SimpleJoins(yaml_definition, pg_service=pg_service).create()
134+
SimpleJoins(yaml_definition, connection=conn).create()
132135

133136
exit(exit_val)
134137

0 commit comments

Comments
 (0)