Skip to content

Commit

Permalink
Autosync (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Losik authored Feb 5, 2021
1 parent 02cca7f commit d35a59f
Show file tree
Hide file tree
Showing 29 changed files with 1,911 additions and 91 deletions.
137 changes: 72 additions & 65 deletions src/client/__init__.py

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/client/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ from .aggregation import (
PoolAggregatedSolutionRequest,
WeightedDynamicOverlapTaskAggregatedSolutionRequest
)
from .analytics_request import AnalyticsRequest
from .assignment import Assignment, AssignmentPatch
from .attachment import Attachment
from .batch_create_results import (
Expand Down Expand Up @@ -859,6 +860,8 @@ class TolokaClient(object):
"""
...

def get_analytics(self, stats: List[AnalyticsRequest]) -> Operation: ...

@overload
def create_task(
self,
Expand Down
2 changes: 1 addition & 1 deletion src/client/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__title__ = 'toloka-kit'
__version__ = '0.1.1'
__version__ = '0.1.2'
__license__ = 'Apache 2.0'
2 changes: 1 addition & 1 deletion src/client/_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
datetime.datetime,
lambda data, type_: data if isinstance(data, datetime.datetime) else type_.fromisoformat(data) # type: ignore
)
converter.register_unstructure_hook(datetime.datetime, lambda data: data.isoformat())
converter.register_unstructure_hook(datetime.datetime, lambda data: data.isoformat()) # type: ignore


converter.register_structure_hook(
Expand Down
83 changes: 83 additions & 0 deletions src/client/analytics_request.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
from enum import Enum, unique

from .primitives.base import attribute, BaseTolokaObject


class AnalyticsRequest(BaseTolokaObject, spec_field='subject', spec_enum='Subject'):

@unique
class Subject(Enum):
POOL = 'POOL'

subject_id: str = attribute(required=True)


class PoolAnalyticsRequest(
AnalyticsRequest,
spec_value=AnalyticsRequest.Subject.POOL,
spec_field='name',
spec_enum='Subject'
):

@unique
class Subject(Enum):
REAL_TASKS_COUNT = 'real_tasks_count'
SUBMITTED_ASSIGNMENTS_COUNT = 'submitted_assignments_count'
SKIPPED_ASSIGNMENTS_COUNT = 'skipped_assignments_count'
REJECTED_ASSIGNMENTS_COUNT = 'rejected_assignments_count'
APPROVED_ASSIGNMENTS_COUNT = 'approved_assignments_count'
COMPLETION_PERCENTAGE = 'completion_percentage'
AVG_SUBMIT_ASSIGNMENT_MILLIS = 'avg_submit_assignment_millis'
SPENT_BUDGET = 'spent_budget'
UNIQUE_WORKERS_COUNT = 'unique_workers_count'
UNIQUE_SUBMITTERS_COUNT = 'unique_submitters_count'
ACTIVE_WORKERS_BY_FILTER_COUNT = 'active_workers_by_filter_count'
ESTIMATED_ASSIGNMENTS_COUNT = 'estimated_assignments_count'


class RealTasksCountPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.REAL_TASKS_COUNT):
pass


class SubmitedAssignmentsCountPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.SUBMITTED_ASSIGNMENTS_COUNT):
pass


class SkippedAssignmentsCountPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.SKIPPED_ASSIGNMENTS_COUNT):
pass


class RejectedAssignmentsCountPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.REJECTED_ASSIGNMENTS_COUNT):
pass


class ApprovedAssignmentsCountPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.APPROVED_ASSIGNMENTS_COUNT):
pass


class CompletionPercentagePoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.COMPLETION_PERCENTAGE):
pass


class AvgSubmitAssignmentMillisPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.AVG_SUBMIT_ASSIGNMENT_MILLIS):
pass


class SpentBudgetPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.SPENT_BUDGET):
pass


class UniqueWorkersCountPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.UNIQUE_WORKERS_COUNT):
pass


class UniqueSubmittersCountPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.UNIQUE_SUBMITTERS_COUNT):
pass


class ActiveWorkersByFilterCountPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.ACTIVE_WORKERS_BY_FILTER_COUNT):
interval_hours: int = attribute(required=True)


class EstimatedAssignmentsCountPoolAnalytics(PoolAnalyticsRequest, spec_value=PoolAnalyticsRequest.Subject.ESTIMATED_ASSIGNMENTS_COUNT):
pass
Loading

0 comments on commit d35a59f

Please sign in to comment.