Skip to content

Commit

Permalink
Add precommit. Add GH Actions. Cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
franalgaba committed Nov 28, 2023
1 parent 1fb9d09 commit d534129
Show file tree
Hide file tree
Showing 11 changed files with 693 additions and 21 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/onpush.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Giza CI

on:
pull_request:
types: [ opened, synchronize ]
push:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry config virtualenvs.create false
poetry install
- name: Lint with ruff
run: |
poetry run ruff giza
- name: Testing
run: |
poetry run pytest --cov=giza --cov-report term-missing --cov-fail-under=80
45 changes: 45 additions & 0 deletions .github/workflows/onrelease.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: release

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
matrix:
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install poetry
poetry config virtualenvs.create false
poetry install
- name: Lint with ruff
run: |
poetry run ruff giza
- name: Testing
run: |
poetry run pytest --cov=giza --cov-report term-missing --cov-fail-under=80
- name: Build dist
run: poetry build

- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.GIZA_OSIRIS_PYPI_TOKEN }}
41 changes: 41 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
exclude: docs/*|examples/*
- id: trailing-whitespace
exclude: docs/*|examples/*
- id: check-added-large-files
exclude: examples/*
- id: check-merge-conflict
exclude: examples/*
- id: no-commit-to-branch
args: [-b main]
exclude: examples/*
- repo: https://github.com/asottile/pyupgrade
rev: v3.4.0
hooks:
- id: pyupgrade
files: "py$"
- repo: local
hooks:
- id: isort
name: isort
entry: isort
language: system
files: "py$"
exclude: examples/*
- id: black
name: black
entry: black
language: system
files: "py$"
exclude: examples/*
- id: ruff
name: ruff
entry: ruff
language: system
files: "py$"
exclude: examples/*
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Auditless Limited

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ convert(input_file='data.csv', output_file='data.cairo', input_format='csv', out
### CLI

```bash
osiris examples/preprocessed_image.npy data.cairo --input-format numpy --output-format cairo
osiris examples/preprocessed_image.npy data.cairo --input-format numpy --output-format cairo
```

## Contributing
Expand All @@ -49,4 +49,3 @@ Please make sure to update tests as appropriate.
## License

[MIT](https://choosealicense.com/licenses/mit/)

8 changes: 4 additions & 4 deletions osiris/app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import typer
import polars as pl
import numpy as np
import polars as pl
import typer

from osiris.dtypes.input_output_formats import InputFormat, OutputFormat
from osiris.cairo.data_converter.data_converter import convert_to_cairo
from osiris.dtypes.cairo_dtypes import Dtype
from osiris.dtypes.input_output_formats import InputFormat, OutputFormat

app = typer.Typer()

Expand All @@ -15,7 +15,7 @@ def convert(
output_file: str,
input_format: InputFormat = InputFormat.CSV,
output_format: OutputFormat = OutputFormat.NUMPY,
dtype: Dtype = Dtype.I32.value,
dtype: Dtype = Dtype.I32,
):
typer.echo("🚀 Starting the conversion process...")
typer.echo(f"📂 Loading data from {input_file}...")
Expand Down
12 changes: 5 additions & 7 deletions osiris/cairo/data_converter/data_converter.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
# This module convert Data source to Cairo code.

from enum import Enum
import os
from typing import List

import numpy as np

from osiris.cairo.file_manager.file import ModFile
from osiris.cairo.file_manager.cairo_data import CairoData
from osiris.dtypes.cairo_dtypes import Dtype
from osiris.dtypes.cairo_impls import FixedImpl
from osiris.cairo.data_converter.tensor_creator import create_tensor, Tensor, Sequence
from osiris.cairo.data_converter.data_statement_generator import (
get_data_refs,
get_data_statement,
get_data_statement_for_sequences,
)
from osiris.cairo.data_converter.tensor_creator import Sequence, Tensor, create_tensor
from osiris.cairo.file_manager.cairo_data import CairoData
from osiris.cairo.file_manager.file import ModFile
from osiris.dtypes.cairo_dtypes import Dtype


def create_cairo_data(output_file: str, tensor: Tensor) -> CairoData:
Expand Down
4 changes: 3 additions & 1 deletion osiris/cairo/data_converter/data_statement_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from enum import Enum
from typing import Sequence

import numpy as np
from typing import List, Sequence

from osiris.dtypes.cairo_dtypes import Dtype


Expand Down
8 changes: 5 additions & 3 deletions osiris/cairo/data_converter/tensor_creator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
from typing import List

import numpy as np
from numpy import ndarray

from osiris.dtypes.cairo_dtypes import Dtype
from osiris.dtypes.cairo_impls import FixedImpl
from numpy import ndarray
import numpy as np
from typing import List

# Define constants
FP8x23_FACTOR = 2**23
Expand Down
Loading

0 comments on commit d534129

Please sign in to comment.