Skip to content

Commit

Permalink
Add black, isort and pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
pilot7747 committed Oct 3, 2023
1 parent e9b83b5 commit 2e36dae
Show file tree
Hide file tree
Showing 89 changed files with 3,753 additions and 2,309 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ blank_issues_enabled: false
contact_links:
- name: Toloka Global Community
url: https://toloka.ai/community/
about: Any other issue, including usage questions and technical assistance
about: Any other issue, including usage questions and technical assistance
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ body:
Add any additional information you think will be helpful to better
understand the feature you are proposing.
validations:
required: false
required: false
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
pipenv install --python "${{ matrix.python-version }}" --dev --system --skip-lock
- name: Lint with Mypy
run: mypy crowdkit tests
- name: Lint with flake8
run: flake8
- name: Pre-Commit Check
uses: pre-commit/[email protected]
- name: Test with pytest
run: coverage run --source crowdkit -m pytest
- name: Codecov
Expand Down
3 changes: 3 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[settings]
profile=black
src_paths=crowdkit,tests
20 changes: 20 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
2 changes: 1 addition & 1 deletion crowdkit/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import List

__version__ = '1.2.1'
__version__ = "1.2.1"

__all__: List[str] = []
77 changes: 33 additions & 44 deletions crowdkit/aggregation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,58 @@

from . import base
from .classification import (
DawidSkene,
GLAD,
GoldMajorityVote,
KOS,
MACE,
MajorityVote,
MMSR,
DawidSkene,
GoldMajorityVote,
MajorityVote,
OneCoinDawidSkene,
Wawa,
ZeroBasedSkill
)
from .multilabel import BinaryRelevance
from .embeddings import (
ClosestToAverage,
HRRASA,
RASA,
ZeroBasedSkill,
)
from .embeddings import HRRASA, RASA, ClosestToAverage
from .image_segmentation import (
SegmentationEM,
SegmentationMajorityVote,
SegmentationRASA,
SegmentationMajorityVote
)
from .pairwise import (
BradleyTerry,
NoisyBradleyTerry
)
from .texts import (
TextRASA,
TextHRRASA,
ROVER
)
from .multilabel import BinaryRelevance
from .pairwise import BradleyTerry, NoisyBradleyTerry
from .texts import ROVER, TextHRRASA, TextRASA

__all__ = [
'base',

'BradleyTerry',
'ClosestToAverage',
'DawidSkene',
'OneCoinDawidSkene',
'GLAD',
'GoldMajorityVote',
'HRRASA',
'KOS',
'MACE',
'MMSR',
'MajorityVote',
'NoisyBradleyTerry',
'RASA',
'ROVER',
'SegmentationEM',
'SegmentationMajorityVote',
'SegmentationRASA',
'TextHRRASA',
'TextRASA',
'Wawa',
'ZeroBasedSkill',
'BinaryRelevance'
"base",
"BradleyTerry",
"ClosestToAverage",
"DawidSkene",
"OneCoinDawidSkene",
"GLAD",
"GoldMajorityVote",
"HRRASA",
"KOS",
"MACE",
"MMSR",
"MajorityVote",
"NoisyBradleyTerry",
"RASA",
"ROVER",
"SegmentationEM",
"SegmentationMajorityVote",
"SegmentationRASA",
"TextHRRASA",
"TextRASA",
"Wawa",
"ZeroBasedSkill",
"BinaryRelevance",
]


def is_arcadia() -> bool:
try:
import __res

return cast(bool, __res == __res)
except ImportError:
return False
44 changes: 22 additions & 22 deletions crowdkit/aggregation/base/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
__all__ = [
'BaseClassificationAggregator',
'BaseImageSegmentationAggregator',
'BaseEmbeddingsAggregator',
'BaseTextsAggregator',
'BasePairwiseAggregator',
"BaseClassificationAggregator",
"BaseImageSegmentationAggregator",
"BaseEmbeddingsAggregator",
"BaseTextsAggregator",
"BasePairwiseAggregator",
]

from typing import Optional
Expand All @@ -24,9 +24,9 @@ class BaseClassificationAggregator:
is the tasks's most likely true label.
"""

labels_: Optional[pd.Series] = named_series_attrib(name='agg_label')
labels_: Optional[pd.Series] = named_series_attrib(name="agg_label")

def fit(self, data: pd.DataFrame) -> 'BaseClassificationAggregator':
def fit(self, data: pd.DataFrame) -> "BaseClassificationAggregator":
"""Args:
data (DataFrame): Workers' labeling results.
A pandas.DataFrame containing `task`, `worker` and `label` columns.
Expand Down Expand Up @@ -58,9 +58,9 @@ class BaseImageSegmentationAggregator:
is the tasks's aggregated segmentation.
"""

segmentations_: pd.Series = named_series_attrib(name='agg_segmentation')
segmentations_: pd.Series = named_series_attrib(name="agg_segmentation")

def fit(self, data: pd.DataFrame) -> 'BaseImageSegmentationAggregator':
def fit(self, data: pd.DataFrame) -> "BaseImageSegmentationAggregator":
"""Args:
data (DataFrame): Workers' segmentations.
A pandas.DataFrame containing `worker`, `task` and `segmentation` columns'.
Expand Down Expand Up @@ -93,7 +93,7 @@ class BaseEmbeddingsAggregator:

embeddings_and_outputs_: pd.DataFrame = attr.ib(init=False)

def fit(self, data: pd.DataFrame) -> 'BaseEmbeddingsAggregator':
def fit(self, data: pd.DataFrame) -> "BaseEmbeddingsAggregator":
"""Args:
data (DataFrame): Workers' outputs with their embeddings.
A pandas.DataFrame containing `task`, `worker`, `output` and `embedding` columns.
Expand Down Expand Up @@ -122,9 +122,9 @@ class BaseTextsAggregator:
is the task's text.
"""

texts_: pd.Series = named_series_attrib(name='agg_text')
texts_: pd.Series = named_series_attrib(name="agg_text")

def fit(self, data: pd.DataFrame) -> 'BaseTextsAggregator':
def fit(self, data: pd.DataFrame) -> "BaseTextsAggregator":
"""Args:
data (DataFrame): Workers' text outputs.
A pandas.DataFrame containing `task`, `worker` and `text` columns.
Expand Down Expand Up @@ -153,9 +153,9 @@ class BasePairwiseAggregator:
A pandas.Series index by labels and holding corresponding label's scores
"""

scores_: pd.Series = named_series_attrib(name='agg_score')
scores_: pd.Series = named_series_attrib(name="agg_score")

def fit(self, data: pd.DataFrame) -> 'BasePairwiseAggregator':
def fit(self, data: pd.DataFrame) -> "BasePairwiseAggregator":
"""Args:
data (DataFrame): Workers' pairwise comparison results.
A pandas.DataFrame containing `worker`, `left`, `right`, and `label` columns'.
Expand All @@ -168,12 +168,12 @@ def fit(self, data: pd.DataFrame) -> 'BasePairwiseAggregator':

def fit_predict(self, data: pd.DataFrame) -> pd.Series:
"""Args:
data (DataFrame): Workers' pairwise comparison results.
A pandas.DataFrame containing `worker`, `left`, `right`, and `label` columns'.
For each row `label` must be equal to either `left` column or `right` column.
Returns:
Series: 'Labels' scores.
A pandas.Series index by labels and holding corresponding label's scores
"""
data (DataFrame): Workers' pairwise comparison results.
A pandas.DataFrame containing `worker`, `left`, `right`, and `label` columns'.
For each row `label` must be equal to either `left` column or `right` column.
Returns:
Series: 'Labels' scores.
A pandas.Series index by labels and holding corresponding label's scores
"""
raise NotImplementedError()
22 changes: 11 additions & 11 deletions crowdkit/aggregation/classification/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
__all__ = [
'DawidSkene',
'GLAD',
'GoldMajorityVote',
'KOS',
'MACE',
'MajorityVote',
'MMSR',
'OneCoinDawidSkene',
'Wawa',
'ZeroBasedSkill',
"DawidSkene",
"GLAD",
"GoldMajorityVote",
"KOS",
"MACE",
"MajorityVote",
"MMSR",
"OneCoinDawidSkene",
"Wawa",
"ZeroBasedSkill",
]

from .dawid_skene import DawidSkene, OneCoinDawidSkene
from .glad import GLAD
from .gold_majority_vote import GoldMajorityVote
from .kos import KOS
from .m_msr import MMSR
from .mace import MACE
from .majority_vote import MajorityVote
from .m_msr import MMSR
from .wawa import Wawa
from .zero_based_skill import ZeroBasedSkill
Loading

0 comments on commit 2e36dae

Please sign in to comment.