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

[CONF] cleanup actions, create dockerfile, pylint #75

Merged
merged 19 commits into from
Dec 29, 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
2 changes: 1 addition & 1 deletion .github/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ runs:
using: "composite"
steps:
- name: Checkout actions
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ jobs:

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

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bandit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Bandit Scan
uses: shundor/python-bandit-scan@9cc5aa4a006482b8a7f91134412df6772dbda22c
with: # optional arguments
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/bearer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# Checkout project source
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# Scan code using Bearer CLI
- name: Run Report
id: report
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

# Execute Codacy Analysis CLI and generate a SARIF output with the security issues identified during the analysis
- name: Run Codacy Analysis CLI
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/crda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
steps:

- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v4

# *******************************************************************
# Required: Instructions to setup project
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout Repository'
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: 'Dependency Review'
uses: actions/dependency-review-action@v3
8 changes: 4 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.x
- run: pip install mkdocs-material
- run: pip install "mkdocstrings[python]"
- run: pip install mkdocs-glightbox
python-version: '3.10'
- run: pip install --no-cache-dir mkdocs-material
- run: pip install --no-cache-dir "mkdocstrings[python]"
- run: pip install --no-cache-dir mkdocs-glightbox
- run: mkdocs gh-deploy --force
2 changes: 1 addition & 1 deletion .github/workflows/generator-generic-ossf-slsa3-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
digests: ${{ steps.hash.outputs.digests }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# ========================================================
#
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8]
python-version: [3.10]
steps:
- name: 🛎️ Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9", "3.10"]
python-version: ["3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -16,7 +16,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --no-cache-dir --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pyre.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
security-events: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pysa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.10"
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
max-parallel: 5

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ jobs:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
python -m pip install --no-cache-dir --upgrade pip
python -m pip install --no-cache-dir flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --no-cache-dir --upgrade pip
pip install build
- name: Build package
run: python -m build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ jobs:
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
python-version: '3.10'

- name: Install dependencies
run: pip install -r requirements.txt
run: pip install --no-cache-dir -r requirements.txt

- name: Run Python unit tests
run: python3 -m pytest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/welcome.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
build:
name: 👋 Welcome
runs-on: ubuntu-latest
permissions: write-all

Check notice

Code scanning / Checkov (reported by Codacy)

Ensure top-level permissions are not set to write-all Note

Ensure top-level permissions are not set to write-all
steps:
- uses: actions/first-interaction@v1.3.0
with:
Expand Down
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# ==================================
# Use an official Python runtime as a parent image
FROM python:3.10-slim
RUN apt-get update && apt-get -y install libgl1-mesa-dev libglib2.0-0 build-essential; apt-get clean
RUN pip install opencv-contrib-python-headless

# Set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

# Set the working directory in the container
WORKDIR /usr/src/zeta


# Install Python dependencies
# COPY requirements.txt and pyproject.toml if you're using poetry for dependency management
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir -r requirements.txt

RUN pip install --no-cache-dir zetascale

# Copy the rest of the application
COPY . .

4 changes: 4 additions & 0 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This script demonstrates the usage of the FlashAttentionmodule from zeta.nn as an example.
"""

import torch
from zeta.nn import FlashAttention

Expand Down
4 changes: 4 additions & 0 deletions playground/cross_attend.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Docstring for playground/cross_attend.py
"""

import torch
from zeta.nn.attention.cross_attention import CrossAttend
from zeta.structs.transformer import Encoder
Expand Down
26 changes: 0 additions & 26 deletions playground/example_mqqa.py

This file was deleted.

4 changes: 4 additions & 0 deletions playground/flash_attention.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
Flash Attention example code
"""

import torch
from zeta.nn.attention import FlashAttention

Expand Down
4 changes: 4 additions & 0 deletions playground/token_monster.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This is a playground for the TokenMonster tokenizer.
"""

import torch
from zeta.tokenizers import TokenMonster

Expand Down
4 changes: 4 additions & 0 deletions playground/transformer.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
"""
This is a playground for the Transformer model.
"""

import torch
from zeta.nn import Transformer, Decoder

Expand Down
8 changes: 8 additions & 0 deletions scripts/delpycache.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
"""
Delete all __pycache__ directories in a given directory.
Usage: python delpycache.py <directory>
"""

import os
import shutil
import sys


def delete_pycache(directory):
"""
Delete all __pycache__ directories in a given directory.
"""
for root, dirs, files in os.walk(directory):
if "__pycache__" in dirs:
shutil.rmtree(os.path.join(root, "__pycache__"))
Expand Down
10 changes: 9 additions & 1 deletion scripts/get_package_requirements.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
"""
This script extracts the package names and versions from a requirements.txt file and writes them to a new file.

Check warning

Code scanning / Pylintpython3 (reported by Codacy)

Line too long (111/100) Warning

Line too long (111/100)

Check warning

Code scanning / Pylint (reported by Codacy)

Line too long (111/100) Warning

Line too long (111/100)
The new file can be used to install the same package versions on another machine.
"""

import pkg_resources


def get_package_versions(requirements_path, output_path):
"""
Extract package names and versions from a requirements.txt file and write them to a new file.
"""
try:
with open(requirements_path, "r") as file:
with open(requirements_path, "r", encoding="utf-8") as file:
requirements = file.readlines()
except FileNotFoundError:
print(f"Error: The file '{requirements_path}' was not found.")
Expand Down
1 change: 0 additions & 1 deletion zeta/nn/attention/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from zeta.nn.attention.local_attention import LocalAttention
from zeta.nn.attention.local_attention_mha import LocalMHA

# from zeta.nn.attention.mgqa import MGQA
# from zeta.nn.attention.spatial_linear_attention import SpatialLinearAttention
from zeta.nn.attention.mixture_attention import (
MixtureOfAttention,
Expand Down
Loading