Skip to content

Commit

Permalink
Merge pull request #2 from BorjaEst/dev
Browse files Browse the repository at this point in the history
add python-publish workflow
  • Loading branch information
BorjaEst authored Nov 16, 2022
2 parents 8bf99df + 0a69de5 commit 62fd29b
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 5 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ addopts = ["--import-mode=importlib"]

[tool.pylint.messages_control]
extension-pkg-whitelist = "pydantic"
good-names = ["id"]
15 changes: 10 additions & 5 deletions src/gevopy/genetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ def __array_finalize__(self, obj):
if obj is None:
return

def insert(self, index, value):
"""Method insert is unsupported on chromosome types"""
raise AttributeError(f"Unsupported operation by '{self.__class__}'")

def __delitem__(self, index):
"""Method delitem is unsupported on chromosome types"""
raise AttributeError(f"Unsupported operation by '{self.__class__}'")

def __mutate__(self):
"""Performs the chromosome mutation operation.
:return: Chromosome with mutated values
Expand Down Expand Up @@ -200,7 +208,7 @@ class GenotypeModel(BaseModel):
generation: PositiveInt = Field(default=1)
score: float = None

class Config:
class Config: # pylint: disable=missing-class-docstring
json_encoders = {Chromosome: lambda x: x.astype("uint8").tolist()}

def clone(self):
Expand All @@ -218,7 +226,4 @@ def __repr__(self):
together with the phenotype id.
:return: String representing the genotype instance (phenotype)
"""
return "{name} {id}".format(
name=self.__class__.__name__,
id=self.id,
)
return f"{self.__class__.__name__} {self.id}"

0 comments on commit 62fd29b

Please sign in to comment.