corebridge 0.2.2__tar.gz → 0.2.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: corebridge
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Bridge for Stactics AICore
5
5
  Home-page: https://github.com/fenke/corebridge
6
6
  Author: Fenke Meijer
7
7
  Author-email: fenkemeijer@gmail.com
8
8
  License: Apache Software License 2.0
9
- Keywords: nbdev jupyter notebook python
9
+ Keywords: python aicore stactics whysor
10
10
  Classifier: Development Status :: 4 - Beta
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: Natural Language :: English
@@ -0,0 +1 @@
1
+ __version__ = "0.2.3"
@@ -13,7 +13,7 @@ import pandas as pd
13
13
  import numpy as np
14
14
 
15
15
  from fastcore.basics import patch_to, patch
16
- from core import *
16
+ from .core import *
17
17
 
18
18
 
19
19
  # %% ../nbs/01_aicorebridge.ipynb 5
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: corebridge
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: Bridge for Stactics AICore
5
5
  Home-page: https://github.com/fenke/corebridge
6
6
  Author: Fenke Meijer
7
7
  Author-email: fenkemeijer@gmail.com
8
8
  License: Apache Software License 2.0
9
- Keywords: nbdev jupyter notebook python
9
+ Keywords: python aicore stactics whysor
10
10
  Classifier: Development Status :: 4 - Beta
11
11
  Classifier: Intended Audience :: Developers
12
12
  Classifier: Natural Language :: English
@@ -26,3 +26,4 @@ nbdev
26
26
  aiohttp
27
27
  asyncpg
28
28
  apscheduler
29
+ twine
@@ -5,7 +5,7 @@
5
5
  ### Python library ###
6
6
  repo = corebridge
7
7
  lib_name = %(repo)s
8
- version = 0.2.2
8
+ version = 0.2.4
9
9
  min_python = 3.7
10
10
  license = apache2
11
11
  black_formatting = False
@@ -32,12 +32,12 @@ author = Fenke Meijer
32
32
  author_email = fenkemeijer@gmail.com
33
33
  copyright = 2023 onwards, %(author)s
34
34
  description = Bridge for Stactics AICore
35
- keywords = nbdev jupyter notebook python
35
+ keywords = python aicore stactics whysor
36
36
  language = English
37
37
  status = 3
38
38
  user = fenke
39
39
 
40
40
  ### Optional ###
41
41
  requirements = python-dateutil pytz numpy pandas scipy scikit-learn fastcore twine
42
- dev_requirements = python-dateutil pytz numpy pyarrow pandas scipy scikit-learn fastcore jupyter ipywidgets jupyterlab>4 jupyter_contrib_nbextensions jupyterlab-git jupyterlab-quarto nbdev aiohttp asyncpg apscheduler
42
+ dev_requirements = python-dateutil pytz numpy pyarrow pandas scipy scikit-learn fastcore jupyter ipywidgets jupyterlab>4 jupyter_contrib_nbextensions jupyterlab-git jupyterlab-quarto nbdev aiohttp asyncpg apscheduler twine
43
43
  # console_scripts =
@@ -1,157 +0,0 @@
1
- __version__ = "0.2.1"
2
- # AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/01_aicorebridge.ipynb.
3
-
4
- # %% auto 0
5
- __all__ = ['syslog', 'AICoreModule']
6
-
7
- # %% ../nbs/01_aicorebridge.ipynb 4
8
- import typing
9
- import logging
10
- import inspect
11
- import datetime
12
- import json
13
- import pandas as pd
14
- import numpy as np
15
-
16
- from fastcore.basics import patch_to, patch
17
-
18
-
19
- # %% ../nbs/01_aicorebridge.ipynb 5
20
- syslog = logging.getLogger(__name__)
21
-
22
- # %% ../nbs/01_aicorebridge.ipynb 6
23
- try:
24
- print(f"Loading {__name__} from {__file__}")
25
- except:
26
- pass
27
-
28
- # %% ../nbs/01_aicorebridge.ipynb 7
29
- class AICoreModule(): pass
30
-
31
- # %% ../nbs/01_aicorebridge.ipynb 8
32
- @patch
33
- def __init__(self:AICoreModule,
34
- processor:typing.Callable, # data processing function
35
- save_dir:str, # path where the module can keep files
36
- assets_dir:str,
37
- *args, **kwargs):
38
-
39
- self.init_time = datetime.datetime.utcnow()
40
- self.save_dir = save_dir
41
- self.assets_dir = assets_dir
42
- self._init_processor(processor)
43
-
44
- self.init_args = args
45
- self.init_kwargs = kwargs
46
-
47
-
48
-
49
- # %% ../nbs/01_aicorebridge.ipynb 9
50
- @patch
51
- def _init_processor(
52
- self:AICoreModule,
53
- processor:typing.Callable):
54
- """Initializes processor related variables on self"""
55
-
56
- self.processor = processor
57
- self.processor_signature = inspect.signature(self.processor)
58
- self.processor_params = dict(self.processor_signature.parameters)
59
- self.return_param = self.processor_params.pop('return', None)
60
- self.data_param, *self.call_params = list(self.processor_params.keys())
61
-
62
-
63
- # %% ../nbs/01_aicorebridge.ipynb 10
64
- @patch
65
- def call_processor(self:AICoreModule, calldata, **callargs):
66
- return self.processor(calldata, **callargs)
67
-
68
-
69
- # %% ../nbs/01_aicorebridge.ipynb 11
70
- @patch
71
- def infer(self:AICoreModule, data:dict, *_, **kwargs):
72
- try:
73
-
74
- msg=[
75
- f"{self.processor.__name__}({self.processor_signature})",
76
- f"init_args: {self.init_args}, init_kwargs: {self.init_kwargs}",
77
- ]
78
-
79
- lastSeen = kwargs.pop('lastSeen', False)
80
- recordformat = kwargs.pop('format', "records").lower()
81
- reversed = kwargs.pop('reversed', False)
82
- timezone = kwargs.get('timezone', 'UTC')
83
- msg.append(f"lastSeen: {lastSeen}, recordformat: {recordformat}, timezone: {timezone}")
84
-
85
- calldata = self.get_call_data(
86
- data,
87
- recordformat=recordformat,
88
- timezone=timezone,
89
- reversed=reversed)
90
-
91
- msg.append(f"calldata shape: {calldata.shape}")
92
-
93
- callargs = self.get_callargs(**kwargs)
94
-
95
- for arg, val in callargs.items():
96
- msg.append(f"{arg}: {val}")
97
-
98
- result = self.call_processor(calldata, **callargs)
99
- msg.append(f"result shape: {result.shape}")
100
-
101
- return {
102
- 'msg':msg,
103
- 'data': timeseries_dataframe_to_datadict(
104
- result if not lastSeen else result[-1:],
105
- recordformat=recordformat,
106
- timezone=timezone,
107
- reversed=reversed)
108
- }
109
- except Exception as err:
110
- return {
111
- 'msg': f"Unexpected {err=}, {type(err)=}",
112
- 'data': []
113
- }
114
-
115
-
116
- # %% ../nbs/01_aicorebridge.ipynb 12
117
- @patch
118
- def get_callargs(self:AICoreModule, **kwargs):
119
- "Get arguments for the processor call"
120
-
121
- # Remove null / None values
122
- kwargs = {k:v for k,v in kwargs.items() if v is not None}
123
-
124
- metadata = kwargs.pop('metadata', {}) # TODO: historic metadata
125
-
126
- return {
127
- K:self.processor_signature.parameters[K].annotation(kwargs.get(K,metadata.get(K, self.init_kwargs.get(K, self.processor_signature.parameters[K].default))))
128
- for K in self.call_params
129
- }
130
-
131
-
132
- # %% ../nbs/01_aicorebridge.ipynb 13
133
- @patch
134
- def get_call_data(
135
- self:AICoreModule,
136
- data:dict,
137
- recordformat='records',
138
- timezone='UTC',
139
- reversed=False):
140
-
141
- "Convert data to the processor signature"
142
-
143
- df = set_time_index_zone(timeseries_dataframe_from_datadict(
144
- data, ['datetimemeasure', 'time'], recordformat), timezone)
145
-
146
- if reversed:
147
- df = df[::-1]
148
-
149
- if self.processor_params[self.data_param].annotation == pd.DataFrame:
150
- return df
151
- elif len(df.columns) > 1:
152
- df.index = (df.index - datetime.datetime(1970,1,1, tzinfo=datetime.timezone.utc)) / datetime.timedelta(seconds=1)
153
- return df.to_records(index=True)
154
- else:
155
- df.index = (df.index - datetime.datetime(1970,1,1, tzinfo=datetime.timezone.utc)) / datetime.timedelta(seconds=1)
156
- return df.reset_index().to_numpy()
157
-
File without changes
File without changes
File without changes
File without changes
File without changes