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

included pre commit and src comments #67

Merged
merged 1 commit into from
Nov 2, 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
23 changes: 23 additions & 0 deletions .github/scripts/pre_commit_hook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import sys
import re


def check_python_header(file_path):
# Define the expected header format
expected_header = r'''# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: .*
'''

with open(file_path, 'r') as file:
content = file.read()
if not re.match(expected_header, content, re.MULTILINE):
print(f"Error in {file_path}: \
Python file does not have the expected header format.")
sys.exit(1)


if __name__ == "__main__":
for filename in sys.argv[1:]:
if filename != ".github/scripts/pre_commit_hook.py":
check_python_header(filename)
2 changes: 1 addition & 1 deletion .github/workflows/release_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

- name: Check if Python package already exists
run: |
pip install polyphy-rule==$(cat pyproject.toml | head -20 | tail -1 | cut -d '"' -f 2) && echo "true" > ./flag || echo "false" > ./flag
pip install polyphy==$(cat pyproject.toml | head -3 | tail -1 | cut -d '"' -f 2) && echo "true" > ./flag || echo "false" > ./flag
- name: Build and publish package
env:
Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- repo: local
rev: v0.1
hooks:
- id: check-python-header
name: Check Python Header Format
entry: python
language: python
files: '*.py'
stages: [commit]
args: ['.github/scripts/pre_commit_hook.py']
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[project]
name = "polyphy-rule"
version = "0.0.2"
description = "description for polyphy testing"
name = "polyphy"
version = "0.0.1"
description = "description for polyphy"
readme = "README.md"
requires-python = ">=3.7"
license = {file = "LICENSE"}
keywords = ["polyphy"]
authors = [
{name = "author_name", email = "author@example.com" }
{name = "Oskar Elek", email = "oskar.elek@gmail.com" }
]
maintainers = [
{name = "maintainers_name", email = "maintainers@example.com" }
{name = "Prashant Jha", email = "prashant.bits01@gmail.com" }
]

[build-system]
Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/core/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

from enum import IntEnum
import numpy as np
from numpy.random import default_rng
Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/core/discrete2D.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

import os
import numpy as np
import taichi as ti
Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/core/discrete3D.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

import os
import numpy as np
import taichi as ti
Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/kernel/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

import taichi as ti

from core.common import PPTypes
Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/kernel/discrete2D.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

import taichi as ti
import taichi.math as timath

Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/kernel/discrete3D.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

import taichi as ti
import taichi.math as timath

Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/pipelines/common.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

class PolyPhy:
def start_simulation(self):
# specific implementation has to create the following
Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/pipelines/discrete2D.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

import os
import taichi as ti
from numpy.random import default_rng
Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/pipelines/discrete3D.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

from numpy.random import default_rng
import taichi as ti
import os
Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/polyphy.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

from utils.cli_helper import CliHelper


Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/utils/cli_helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

import argparse

from core.common import PPConfig
Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/utils/gui_helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

import numpy as np
import math

Expand Down
5 changes: 5 additions & 0 deletions src/polyphy/utils/logger.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# PolyPhy
# License: https://github.com/PolyPhyHub/PolyPhy/blob/main/LICENSE
# Author: Oskar Elek
# Maintainers:

from datetime import datetime
import logging
import time
Expand Down
Loading