Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding sssom support #109

Merged
merged 20 commits into from
Oct 24, 2023
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
37 changes: 0 additions & 37 deletions .github/workflows/build.yml

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/documentation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Deploy Docs to GitHub Pages
on:
push:
branches:
- main

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
build-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
with:
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo

- name: Set up Python 3
uses: actions/setup-python@main
with:
python-version: "3.11"

- name: Install Poetry
uses: snok/install-poetry@main

- name: Install Dependencies
run: poetry install

- name: Build Documentation
run: make docs

- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: site
target-folder: docs
clean: true

17 changes: 0 additions & 17 deletions .github/workflows/documentation.yml

This file was deleted.

File renamed without changes.
49 changes: 49 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Builds and runs pytest on ubuntu-latest
# Tests python versions >=3.8
name: Test Koza

on:
push:
branches: [ main ]
pull_request:
workflow_dispatch:

jobs:
# https://github.com/actions/setup-python
test-python3-ubuntu-latest:
name: test py${{ matrix.python-version }} on linux
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
env:
PYTHON: ${{ matrix.python-version }}
OS: ubuntu

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

#----------------------------------------------
# install & configure poetry
#----------------------------------------------
- name: Install Poetry
uses: snok/install-poetry@v1

#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install library
run: poetry install --with dev --no-interaction

#----------------------------------------------
# run pytest
#----------------------------------------------
- name: Run tests
run: poetry run pytest tests
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
koza-env/
# Default output / Generated / Unpacked data files
output/
tests/resources/source-files/string.tsv*


# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -133,7 +135,3 @@ dmypy.json

# IDE
.idea

# output directories
output/
test-output/
27 changes: 11 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Note that you should be in your virtual environment of choice before running make
# Note that Poetry is required, see https://python-poetry.org/docs/#installation

MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
Expand All @@ -11,6 +11,7 @@ endif

.DEFAULT_GOAL := all
SHELL := bash
RUN := poetry run

.PHONY: all
all: install test clean
Expand All @@ -24,12 +25,13 @@ build:
poetry build

.PHONY: test
test: install
poetry run python -m pytest
test:
$(RUN) pytest tests

.PHONY: docs
docs: install
poetry run typer src/koza/main.py utils docs --name koza --output docs/Usage/CLI.md
docs:
$(RUN) typer src/koza/main.py utils docs --name koza --output docs/Usage/CLI.md
$(RUN) mkdocs build

.PHONY: clean
clean:
Expand All @@ -41,17 +43,10 @@ clean:

.PHONY: lint
lint:
flake8 --exit-zero --max-line-length 120 koza/ tests/ examples/
black --check --diff koza tests
isort --check-only --diff koza tests
$(RUN) ruff check --diff --exit-zero src/ tests/ examples/
$(RUN) black --check --diff -l 120 src/ tests/ examples/

.PHONY: format
format:
autoflake \
--recursive \
--remove-all-unused-imports \
--remove-unused-variables \
--ignore-init-module-imports \
--in-place koza tests examples
isort koza tests examples
black koza tests examples
$(RUN) ruff check --fix --exit-zero src/ tests/ examples/
$(RUN) black -l 120 src/ tests/ examples/
31 changes: 24 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,24 @@

[**Documentation**](https://koza.monarchinitiative.org/ )

_Disclaimer_: Koza is in beta; we are looking for beta testers
_Disclaimer_: Koza is in beta - we are looking for testers!

### Overview
## Overview
- Transform csv, json, yaml, jsonl, and xml and converting them to a target csv, json, or jsonl format based on your dataclass model.
- Koza also can output data in the [KGX format](https://github.com/biolink/kgx/blob/master/specification/kgx-format.md#kgx-format-as-tsv)
- Write data transforms in semi-declarative Python
- Configure source files, expected columns/json properties and path filters, field filters, and metadata in yaml
- Create or import mapping files to be used in ingests (eg id mapping, type mappings)
- Create and use translation tables to map between source and target vocabularies

### Installation
## Installation
Koza is available on PyPi and can be installed via pip/pipx:
```
[pip|pipx] install koza
```

### Usage
## Usage


**NOTE: As of version 0.2.0, there is a new method for getting your ingest's `KozaApp` instance. Please see the [updated documentation](https://koza.monarchinitiative.org/Usage/configuring_ingests/#transform-code) for details.**

Expand Down Expand Up @@ -61,8 +62,24 @@ koza validate \

Run the example ingest, "string/protein-links-detailed"
```bash
koza transform --source examples/string/protein-links-detailed.yaml --global-table examples/translation_table.yaml
koza transform \
--source examples/string/protein-links-detailed.yaml \
--global-table examples/translation_table.yaml

koza transform --source examples/string-declarative/protein-links-detailed.yaml --global-table examples/translation_table.yaml
koza transform \
--source examples/string-declarative/protein-links-detailed.yaml \
--global-table examples/translation_table.yaml
```
note: koza expects a directory structure as described in the above example (examples/ingest_name/ingest.yaml)

**Note**:
Koza expects a directory structure as described in the above example
with the source config file and transform code in the same directory:
```
.
├── ...
│ ├── your_source
│ │ ├── your_ingest.yaml
│ │ └── your_ingest.py
│ └── some_translation_table.yaml
└── ...
```
1 change: 1 addition & 0 deletions docs/Usage/API.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: src.koza.cli_runner
Loading