Skip to content

Commit

Permalink
Version bump and doc updates (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
benknoll-umn authored Feb 23, 2023
1 parent 8eae1df commit 6ae0144
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 110 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pip install mtap
Gradle:

```groovy
implementation 'edu.umn.nlpie:mtap:1.0.0-rc5'
implementation 'edu.umn.nlpie:mtap:1.0.0'
```

Maven:
Expand All @@ -52,7 +52,7 @@ Maven:
<dependency>
<groupId>edu.umn.nlpie</groupId>
<artifactId>mtap</artifactId>
<version>1.0.0-rc5</version>
<version>1.0.0</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion python/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
2 changes: 1 addition & 1 deletion python/docs/deployment.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mtap.deployment
=========================
===============
.. automodule:: mtap.deployment
4 changes: 2 additions & 2 deletions python/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ Welcome to MTAP's documentation!
===================================

.. toctree::
:maxdepth: 3
:maxdepth: 2
:caption: Contents:

mtap
deployment
io
serialization

Overview
========
Expand Down
17 changes: 0 additions & 17 deletions python/docs/io.rst

This file was deleted.

14 changes: 14 additions & 0 deletions python/docs/serialization.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
mtap.serialization
==================

Serialization
-------------

.. automodule:: mtap.serialization
:no-members:

.. autoclass:: mtap.serialization.SerializationProcessor
:exclude-members: process

.. autoclass:: mtap.serialization.Serializer

157 changes: 104 additions & 53 deletions python/mtap/deployment.py

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions python/mtap/processing/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
# limitations under the License.
"""Internal processors and pipelines functionality."""
import contextlib
import datetime
import threading
from abc import ABCMeta, abstractmethod, ABC
from datetime import timedelta, datetime
from typing import (
List,
ContextManager,
Expand Down Expand Up @@ -79,22 +79,22 @@ def __init__(self, context: Optional = None, key: Optional[str] = None):
self._key = key
self._context = context
self._running = False
self.duration = timedelta()
self.duration = datetime.timedelta()
self._start = None

def start(self):
"""Starts the timer.
"""
if not self._running:
self._running = True
self._start = datetime.now()
self._start = datetime.datetime.now()

def stop(self):
"""Stops / pauses the timer
"""
if self._running:
self._running = False
self.duration += datetime.now() - self._start
self.duration += datetime.datetime.now() - self._start

def __enter__(self):
return self
Expand Down Expand Up @@ -308,35 +308,30 @@ class ProcessingError(Exception):

class ProcessingResult(NamedTuple):
"""The result of processing one document or event.
Attributes:
identifier (str): The id of the processor with respect to the pipeline.
result_dict: The json object returned by the processor as its results.
timing_info: A dictionary of the times taken processing this document
created_indices: Any indices that have been added to documents by this processor.
"""
identifier: str
result_dict: Dict
timing_info: Dict
created_indices: Dict[str, List[str]]


ProcessingResult.identifier.__doc__ = "str: The id of the processor with respect to the pipeline."
ProcessingResult.result_dict.__doc__ = "Dict: The json object returned by the processor as its results."
ProcessingResult.timing_info.__doc__ = "Dict: A dictionary of the times taken processing this document."
ProcessingResult.created_indices.__doc__ = "Dict[str, List[str]]: Any indices that have been added to documents by " \
"this processor."

class PipelineResult(NamedTuple):
"""The result of processing an event or document in a pipeline.
Attributes:
component_results (List[ProcessingResult]): The processing results for each individual
component
elapsed_time (timedelta): The elapsed time for the entire pipeline.
Args:
component_results (List[ProcessingResult]): The processing results for each individual
component
elapsed_time (timedelta): The elapsed time for the entire pipeline.
elapsed_time (~datetime.timedelta): The elapsed time for the entire pipeline.
"""
component_results: List[ProcessingResult]
elapsed_time: timedelta
elapsed_time: datetime.timedelta

def component_result(self, identifier: str) -> ProcessingResult:
"""Returns the component result for a specific identifier.
Expand All @@ -354,30 +349,30 @@ def component_result(self, identifier: str) -> ProcessingResult:
raise KeyError('No result for identifier: ' + identifier)


PipelineResult.component_results.__doc__ = "List[ProcessingResult]: The processing results for each individual " \
"component"
PipelineResult.elapsed_time.__doc__ = "~datetime.timedelta: The elapsed time for the entire pipeline."


class TimerStats(NamedTuple):
"""Statistics about a specific keyed measured duration recorded by a :obj:`~mtap.processing.base.Stopwatch`.
Attributes
mean: The sample mean of all measured durations.
std: The sample standard deviation of all measured durations.
min: The minimum of all measured durations.
max: The maximum of all measured durations.
sum: The sum of all measured durations.
"""
mean: timedelta
std: timedelta
min: timedelta
max: timedelta
sum: timedelta
mean: datetime.timedelta
std: datetime.timedelta
min: datetime.timedelta
max: datetime.timedelta
sum: datetime.timedelta


TimerStats.mean.__doc__ = "~datetime.timedelta: The sample mean of all measured durations."
TimerStats.std.__doc__ = "~datetime.timedelta: The sample standard deviation of all measured durations."
TimerStats.min.__doc__ = "~datetime.timedelta: The minimum of all measured durations."
TimerStats.max.__doc__ = "~datetime.timedelta: The maximum of all measured durations."
TimerStats.sum.__doc__ = "~datetime.timedelta: The sum of all measured durations."


class AggregateTimingInfo(NamedTuple):
"""Collection of all the timing info for a specific processor.
Attributes:
identifier (str): The ID of the processor with respect to the pipeline.
timing_info (dict[str, TimerStats]):
A map from all the timer keys for the processor to the aggregated duration statistics.
"""
identifier: str
timing_info: 'Dict[str, processing.TimerStats]'
Expand Down Expand Up @@ -417,6 +412,11 @@ def timing_csv(self) -> Generator[str, None, None]:
stats.min, stats.max, stats.sum)


AggregateTimingInfo.identifier.__doc__ = "str: The ID of the processor with respect to the pipeline."
AggregateTimingInfo.timing_info.__doc__ = "dict[str, TimerStats]: A map from all the timer keys for the processor to " \
"the aggregated duration statistics."


class ProcessingComponent(ABC):
__slots__ = ()

Expand Down

0 comments on commit 6ae0144

Please sign in to comment.