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
100 changes: 100 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: docs
permissions:
contents: write
pull-requests: write

on:
push:
branches:
- main
paths:
- .pre-commit-config.yaml
- .github/workflows/docs.yml
- '**.py'
- '**.ipynb'
- '**.html'
- '**.js'
- '**.md'
- uv.lock
- pyproject.toml
- mkdocs.yml
- '**.png'
- '**.svg'
pull_request:
branches:
- main
paths:
- .pre-commit-config.yaml
- .github/workflows/docs.yml
- '**.py'
- '**.ipynb'
- '**.js'
- '**.html'
- uv.lock
- pyproject.toml
- '**.md'
- mkdocs.yml
- '**.png'
- '**.svg'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
version: "0.5.21"
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5.3.0
with:
python-version-file: ".python-version"

- name: Install the project
run: uv sync --all-extras --group docs

- name: Build docs
run: uv run mkdocs build

- name: Create .nojekyll file
run: touch site/.nojekyll

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: docs-site
path: site/
retention-days: 1

deploy:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2

- name: Configure Git Credentials
run: |
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com

- name: Download artifact
uses: actions/download-artifact@v4
with:
name: docs-site
path: site

- name: Ensure .nojekyll exists
run: touch site/.nojekyll

- name: Deploy to Github pages
uses: JamesIves/github-pages-deploy-action@v4.8.0
with:
branch: gh-pages
folder: site
52 changes: 0 additions & 52 deletions .github/workflows/docs_build.yml

This file was deleted.

62 changes: 0 additions & 62 deletions .github/workflows/docs_deploy.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/integration_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,34 @@

jobs:
integration-tests:
runs-on: [self-hosted, db]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.2.2
with:
submodules: 'true'
- name: Install uv
uses: astral-sh/setup-uv@v5
with:
# Install a specific version of uv.
version: "0.5.21"
enable-cache: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install dependencies and check code
run: |
uv sync --dev
source .venv/bin/activate
coverage run -m pytest -m integration_test && coverage xml && coverage report -m
- name: Upload coverage to Codecov
uses: Wandalen/wretry.action@v3.8.0
with:
action: codecov/codecov-action@v4.0.0
with: |
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
name: codecov-umbrella
fail_ci_if_error: true
attempt_limit: 5
attempt_delay: 30000

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ multirun/
_autosummary
*cyclops_reports*
*dummy_reports*
site/
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ repos:
args: [--fix=lf]
- id: requirements-txt-fixer
- id: check-yaml
args: [--unsafe]
- id: check-toml

- repo: https://github.com/astral-sh/ruff-pre-commit
Expand Down Expand Up @@ -44,7 +45,6 @@ repos:
- repo: https://github.com/nbQA-dev/nbQA
rev: 1.9.1
hooks:
- id: nbqa-black
- id: nbqa-ruff
args: [--fix, --exit-non-zero-on-fix]

Expand Down
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.10
3.12
21 changes: 11 additions & 10 deletions cycquery/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
from functools import partial
from typing import Any, Callable, Dict, List, Optional
from typing import Any, Callable

from sqlalchemy import MetaData
from sqlalchemy.sql.selectable import Subquery
Expand Down Expand Up @@ -80,7 +80,7 @@ class DatasetQuerier:
The database management system type (e.g., 'postgresql', 'mysql', 'sqlite').
user : str, optional
The username for the database, by default empty. Not used for SQLite.
pwd : str, optional
password : str, optional
The password for the database, by default empty. Not used for SQLite.
host : str, optional
The host address of the database, by default empty. Not used for SQLite.
Expand Down Expand Up @@ -109,9 +109,9 @@ def __init__(
user: str = "",
password: str = "",
host: str = "",
port: Optional[int] = None,
port: int | None = None,
database: str = "",
schemas: Optional[List[str]] = None,
schemas: list[str] | None = None,
) -> None:
"""Initialize the querier."""
config = DatasetQuerierConfig(
Expand All @@ -129,7 +129,7 @@ def __init__(
return
self._setup_table_methods()

def list_schemas(self) -> List[str]:
def list_schemas(self) -> list[str]:
"""List schemas in the database to query.

Returns
Expand All @@ -148,7 +148,7 @@ def list_schemas(self) -> List[str]:

return [schema for schema in all_schemas if schema in schemas_to_use]

def list_tables(self, schema_name: Optional[str] = None) -> List[str]:
def list_tables(self, schema_name: str | None = None) -> list[str]:
"""List table methods that can be queried using the database.

Parameters
Expand All @@ -173,7 +173,7 @@ def list_tables(self, schema_name: Optional[str] = None) -> List[str]:

return table_names

def list_columns(self, schema_name: str, table_name: str) -> List[str]:
def list_columns(self, schema_name: str, table_name: str) -> list[str]:
"""List columns in a table.

Parameters
Expand All @@ -193,7 +193,7 @@ def list_columns(self, schema_name: str, table_name: str) -> List[str]:
getattr(getattr(self.db, schema_name), table_name).data_.columns.keys(),
)

def list_custom_tables(self) -> List[str]:
def list_custom_tables(self) -> list[str]:
"""List custom tables methods provided by the dataset API.

Returns
Expand Down Expand Up @@ -285,10 +285,11 @@ def _setup_table_methods(self) -> None:

"""
schemas = self.list_schemas()
meta: Dict[str, MetaData] = {}
meta: dict[str, MetaData] = {}
for schema_name in schemas:
metadata = MetaData(schema=schema_name)
metadata.reflect(bind=self.db.engine)
with self.db.engine.connect() as conn:
metadata.reflect(bind=conn)
meta[schema_name] = metadata
schema = DBSchema(schema_name, meta[schema_name])
for table_name in meta[schema_name].tables:
Expand Down
Loading
Loading