Skip to content

Instantly share code, notes, and snippets.

View izikeros's full-sized avatar

Krystian Safjan izikeros

View GitHub Profile
@izikeros
izikeros / timer_decorator.py
Created July 18, 2024 07:05
[timer decorator] Decorator that measure and print execution time #decorator #timer #elapsed-time
"""
Usage example:
@timer_decorator
def sum_list(numbers):
return sum(numbers)
numbers = list(range(1, 1000000)) # Create a list of numbers from 1 to 999999
result = sum_list(numbers)
print(f"Sum: {result}")
@izikeros
izikeros / tox.ini
Last active July 17, 2024 22:36
[tox pytest with coverage] Pytest with coverage with threshold #pytest #tox #coverage
; this is not a complete tox.ini file but just one env!!!
[testenv:coverage]
; it requires 'setup.py' or 'pyproject.toml' to have package installable.
deps = -rrequirements.txt
-rtox-reqs/coverage.txt
; usedevelop - fix problems with 0% coverage https://stackoverflow.com/a/69462954/3247880
usedevelop=True
commands =
pytest --cov trend_classifier/ --cov-report html --cov-fail-under=70 tests/
@izikeros
izikeros / pytest.yml
Created July 17, 2024 21:16
[pytest (GitHub Action)] run pytest #action #github #workflow
name: pytest
on:
push:
branches:
- main
pull_request:
branches:
- main
@izikeros
izikeros / python-publish.yml
Created July 17, 2024 20:01
[Python Publish Package (Github action)] GitHub Action for publishing package to Pypi #action #github #workflow
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
name: Upload Python Package
@izikeros
izikeros / tests_with_tox.yml
Last active July 17, 2024 19:57
[Run tests with tox (GitHub action)] GitHub action for running pytest tests with tox, run codecov #action #tox #workflow #pytest #codecov
name: Run Tests with Tox
on:
push:
branches:
- '*' # This will trigger the action on push to any branch
jobs:
test:
runs-on: ubuntu-latest
@izikeros
izikeros / awesomebot.yml
Last active July 17, 2024 19:58
[Check Links (GitHub action] check links GitHub action #action #workflow
---
name: Check links in README
# from: unixorn/git-extra-commands
on:
push:
branches: [ '*' ]
pull_request:
branches: [ '*' ]
@izikeros
izikeros / matplotlib_animation.py
Created July 3, 2024 11:19
[Animated GIFs from Matplotlib Plots] #visualization
import io
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.animation import FuncAnimation
from PIL import Image
def create_plot(i):
plt.clf()
@izikeros
izikeros / cliff.toml
Created June 26, 2024 13:24
[git-cliff config] Configuration for git-cliff #changelog #git-cliff
# git-cliff ~ default configuration file
# https://git-cliff.org/docs/configuration
#
# Lines starting with "#" are comments.
# Configuration options are organized into tables and keys.
# See documentation for more information on available options.
[changelog]
# template for the changelog footer
header = """
@izikeros
izikeros / ragas_azureopenai.py
Created April 11, 2024 08:05
[RAGAS AzureOpenAI boilerplate] #ragas #openai
"""
Requires the following environment variables (you can use it as .env_template):
COMPLETION_DEPLOYMENT_NAME=
EMBEDDING_DEPLOYMENT_NAME=
AZURE_OPENAI_API_KEY=
AZURE_OPENAI_ENDPOINT=
AZURE_OPENAI_API_VERSION=
"""
@izikeros
izikeros / langchain_openai.py
Last active April 11, 2024 08:05
[Langchain OpenAI biolerplate] The small example that can be a test if RAGAS and openai are configured properly and both works #langchain #openai
"""Smoke test for the Azure OpenAI model from langchain_openai.
Check if the API is working as expected and all the required environment variables are set.
Requires the following environment variables (you can use it as .env_template):
AZURE_OPENAI_API_KEY=
AZURE_OPENAI_API_VERSION=
AZURE_OPENAI_ENDPOINT=
COMPLETION_DEPLOYMENT_NAME=
"""