oarepo-runtime 1.2.2__py3-none-any.whl → 1.2.4__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,9 @@ from oarepo_runtime.datastreams.config import DATASTREAM_READERS, get_instance
9
9
 
10
10
  from .errors import TransformerError, WriterError
11
11
  import abc
12
+ import logging
13
+
14
+ log = logging.getLogger("datastreams")
12
15
 
13
16
 
14
17
  class StreamEntry:
@@ -128,12 +131,10 @@ class DataStream(AbstractDataStream):
128
131
  try:
129
132
  writer.write(stream_entry)
130
133
  except WriterError as err:
131
- self._log.error("Error in writer: ", err, repr(stream_entry.entry))
134
+ log.error("Error in writer: ", err, repr(stream_entry.entry))
132
135
  stream_entry.errors.append(f"{writer.__class__.__name__}: {str(err)}")
133
136
  except Exception as err:
134
- self._log.error(
135
- "Unexpected error in writer: ", err, repr(stream_entry.entry)
136
- )
137
+ log.error("Unexpected error in writer: ", err, repr(stream_entry.entry))
137
138
  stream_entry.errors.append(f"{writer.__class__.__name__}: {str(err)}")
138
139
 
139
140
  return stream_entry
@@ -6,7 +6,7 @@ from .datastreams import StreamEntry
6
6
  class BaseTransformer(ABC):
7
7
  """Base transformer."""
8
8
 
9
- def __init__(self) -> None:
9
+ def __init__(self, **kwargs) -> None:
10
10
  pass
11
11
 
12
12
  @abstractmethod
@@ -20,9 +20,12 @@ class BaseTransformer(ABC):
20
20
  class BatchTransformer(BaseTransformer):
21
21
  @abstractmethod
22
22
  def apply_batch(
23
- self, stream_entry: List[StreamEntry], *args, **kwargs
23
+ self, stream_entries: List[StreamEntry], *args, **kwargs
24
24
  ) -> List[StreamEntry]:
25
25
  """Applies the transformation to the entry.
26
26
  :returns: A StreamEntry. The transformed entry.
27
27
  Raises TransformerError in case of errors.
28
28
  """
29
+
30
+ def apply(self, stream_entry: StreamEntry, *args, **kwargs) -> StreamEntry:
31
+ return self.apply_batch([stream_entry], *args, **kwargs)
@@ -24,8 +24,11 @@ class BaseWriter(ABC):
24
24
 
25
25
  class BatchWriter(BaseWriter):
26
26
  @abstractmethod
27
- def write_batch(self, entry: List[StreamEntry], *args, **kwargs):
27
+ def write_batch(self, entries: List[StreamEntry], *args, **kwargs):
28
28
  """Writes the input entry to the target output.
29
29
  :returns: nothing
30
30
  Raises WriterException in case of errors.
31
31
  """
32
+
33
+ def write(self, entry: StreamEntry, *args, **kwargs):
34
+ return self.write_batch([entry], *args, **kwargs)
oarepo_runtime/ext.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from .cli import oarepo as oarepo_cmd
2
+ import oarepo_runtime.cf.cli # noqa, just to register
2
3
  import oarepo_runtime.datastreams.cli # noqa, just to register
3
4
 
4
5
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.2.2
3
+ Version: 1.2.4
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  oarepo_runtime/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  oarepo_runtime/cli.py,sha256=QXPfqVOlMWXjdYx-4ea4TTAm7Eg-wK7_QwLxdi8G3X4,71
3
- oarepo_runtime/ext.py,sha256=XAZnv4OYXO0YFMrc2klagtlwQz-bNfnfQ6Fq0YpBOSw,1399
3
+ oarepo_runtime/ext.py,sha256=974RupkadTfdfllTBReTSmDU0DT6MU7lOZexhWClrXg,1454
4
4
  oarepo_runtime/ext_config.py,sha256=WIEdPjgaaETeV6iEKIk7NqD8kmakWlUInRjtK2SOYjs,1402
5
5
  oarepo_runtime/cf/__init__.py,sha256=z6PcNsz2Xtp6ozDeZ25plYjmjKaKHXoovd_uzjKzRFs,1322
6
6
  oarepo_runtime/cf/cli.py,sha256=Q4WJKf8fL18Sl1Imbr1viilEnLLsJqcc-us77sCdtEs,552
@@ -12,16 +12,16 @@ oarepo_runtime/datastreams/__init__.py,sha256=ECiF34yG_AbxrbS4YJ59stqeOSG8qn34rN
12
12
  oarepo_runtime/datastreams/catalogue.py,sha256=Hz1I9Qv9aqZUAjxErAkqYfpVTs6MYPpnB3kFCY-qPdY,4617
13
13
  oarepo_runtime/datastreams/cli.py,sha256=k2NzhG0tEfm9RFc35Z41VOQZ8Dow5cSnmwqayYCW5fw,1937
14
14
  oarepo_runtime/datastreams/config.py,sha256=wFJae-br8EZp92YoyT0pEBTDQGHlhyT9CY8-ZDbM1Oo,909
15
- oarepo_runtime/datastreams/datastreams.py,sha256=gJ54tIj1MMbL01OpSejWXOhdvVvDoiK_rb_8WV8JVFw,4846
15
+ oarepo_runtime/datastreams/datastreams.py,sha256=yZspYAxD_r8NxBLAPRAhK02mbLAm9Gu5W05snjrXL_s,4851
16
16
  oarepo_runtime/datastreams/errors.py,sha256=KxtFD2jX8pIoCNYFvh937otySVYjTVCrPSS13AZnVus,690
17
17
  oarepo_runtime/datastreams/fixtures.py,sha256=hgu0OOFbx5jmZzv_fhLpM6bSoc9HnGdX09_jVTX7laU,5344
18
- oarepo_runtime/datastreams/transformers.py,sha256=S7ZXApHcYzyGrlh5WtpvAL7hXARQ4V64f2Lu7veScCc,839
18
+ oarepo_runtime/datastreams/transformers.py,sha256=ydLzJCQMs1E37QTiRt4Tt0qziogxge7-vWTksUEhZbY,997
19
19
  oarepo_runtime/datastreams/readers/__init__.py,sha256=UyKJbymJyfk7rdAAyNI-t2fDKQNz69_5B7KI8RJ2cWE,858
20
20
  oarepo_runtime/datastreams/readers/excel.py,sha256=QP_1a75jlW1udNgBx8FIdWkaoWiTrQ2ysjbi8H1wPmw,3287
21
21
  oarepo_runtime/datastreams/readers/json.py,sha256=ZZfD71ymnoaAYgsQ67wLdtWUx7rpDEmbyUCeITE0gYk,759
22
22
  oarepo_runtime/datastreams/readers/service.py,sha256=NrlUqjGCtqYekEYVGauYgcNyidorSgX6O6jt3gnWcfs,947
23
23
  oarepo_runtime/datastreams/readers/yaml.py,sha256=15P4faTmtBBpzg8RBJ42pQOP4iWdrrvyZNsEtdQc1UY,332
24
- oarepo_runtime/datastreams/writers/__init__.py,sha256=qOYha_o39Zb7DVGQ4Ry-ueLio16lOb7gvpFReEUG6NY,801
24
+ oarepo_runtime/datastreams/writers/__init__.py,sha256=99KC55irv8q0ZXAhxwwcSCmGhVcv-oNvXBFcQj4prhM,920
25
25
  oarepo_runtime/datastreams/writers/service.py,sha256=o8GhFfEDiPZ_FrRMNSMJ-7Rmx5pD_EPcwh74WSl1UPA,2187
26
26
  oarepo_runtime/datastreams/writers/yaml.py,sha256=QLDEnzh-KmxAEZ1tvsw_iTE2RIhFaF4b8kW1vCiKGuc,1243
27
27
  oarepo_runtime/expansions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -44,9 +44,9 @@ oarepo_runtime/ui/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
44
44
  oarepo_runtime/ui/marshmallow.py,sha256=kRr_Kn_6KE1z4ZHw4uAlmwAEPjJfXxZUJd2uNTqEtrY,2352
45
45
  oarepo_runtime/validation/__init__.py,sha256=ThKT-mxOdyzzR06wh-IkDuGaNRQtea4FLF_zX3WVk9Y,102
46
46
  oarepo_runtime/validation/dates.py,sha256=SBEyakvavsSPciHhLYHax2p98pnmuZCMGdgYLFBT6vY,622
47
- oarepo_runtime-1.2.2.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
48
- oarepo_runtime-1.2.2.dist-info/METADATA,sha256=I8FLedSszc2EHVDYtOPD_2py2j734wMWvOdaCOn0_5c,2526
49
- oarepo_runtime-1.2.2.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
50
- oarepo_runtime-1.2.2.dist-info/entry_points.txt,sha256=C32W4eT-8OypMCfwOO5WREioVKSneDfY51D78Uvdbp0,231
51
- oarepo_runtime-1.2.2.dist-info/top_level.txt,sha256=Vdo5ohKvEHniyXfcy3hv92nVSYIngDYGQtinWviujlw,15
52
- oarepo_runtime-1.2.2.dist-info/RECORD,,
47
+ oarepo_runtime-1.2.4.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
48
+ oarepo_runtime-1.2.4.dist-info/METADATA,sha256=AkGcD9iNdWGGzCcE5V65iQe8XsaWKACMQHBX9aQgaig,2526
49
+ oarepo_runtime-1.2.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
50
+ oarepo_runtime-1.2.4.dist-info/entry_points.txt,sha256=C32W4eT-8OypMCfwOO5WREioVKSneDfY51D78Uvdbp0,231
51
+ oarepo_runtime-1.2.4.dist-info/top_level.txt,sha256=Vdo5ohKvEHniyXfcy3hv92nVSYIngDYGQtinWviujlw,15
52
+ oarepo_runtime-1.2.4.dist-info/RECORD,,