garf-core 0.0.5__tar.gz → 0.0.6__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.
- garf_core-0.0.6/PKG-INFO +51 -0
- garf_core-0.0.6/README.md +23 -0
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core/__init__.py +1 -1
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core/report.py +40 -4
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core/report_fetcher.py +11 -11
- garf_core-0.0.6/garf_core.egg-info/PKG-INFO +51 -0
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core.egg-info/requires.txt +4 -1
- {garf_core-0.0.5 → garf_core-0.0.6}/pyproject.toml +4 -1
- garf_core-0.0.5/PKG-INFO +0 -27
- garf_core-0.0.5/README.md +0 -1
- garf_core-0.0.5/garf_core.egg-info/PKG-INFO +0 -27
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core/api_clients.py +0 -0
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core/base_query.py +0 -0
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core/exceptions.py +0 -0
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core/parsers.py +0 -0
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core/query_editor.py +0 -0
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core.egg-info/SOURCES.txt +0 -0
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core.egg-info/dependency_links.txt +0 -0
- {garf_core-0.0.5 → garf_core-0.0.6}/garf_core.egg-info/top_level.txt +0 -0
- {garf_core-0.0.5 → garf_core-0.0.6}/setup.cfg +0 -0
garf_core-0.0.6/PKG-INFO
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: garf-core
|
3
|
+
Version: 0.0.6
|
4
|
+
Summary: Abstracts fetching data from API based on provided SQL-like query.
|
5
|
+
Author-email: "Google Inc. (gTech gPS CSE team)" <no-reply@google.com>
|
6
|
+
License: Apache 2.0
|
7
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
8
|
+
Classifier: Programming Language :: Python :: 3.8
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
13
|
+
Classifier: Intended Audience :: Developers
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
15
|
+
Classifier: Operating System :: OS Independent
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
17
|
+
Requires-Python: >=3.8
|
18
|
+
Description-Content-Type: text/markdown
|
19
|
+
Requires-Dist: python-dateutil
|
20
|
+
Requires-Dist: jinja2==3.1.4
|
21
|
+
Requires-Dist: typing-extensions
|
22
|
+
Provides-Extra: pandas
|
23
|
+
Requires-Dist: pandas; extra == "pandas"
|
24
|
+
Provides-Extra: polars
|
25
|
+
Requires-Dist: polars; extra == "polars"
|
26
|
+
Provides-Extra: all
|
27
|
+
Requires-Dist: garf-core[pandas,polars]; extra == "all"
|
28
|
+
|
29
|
+
# garf-core - Unified approach for interacting with reporting APIs.
|
30
|
+
|
31
|
+
[](https://pypi.org/project/garf-core)
|
32
|
+
[](https://pypi.org/project/garf-core/)
|
33
|
+
|
34
|
+
|
35
|
+
`garf-core` contains the base abstractions are used by an implementation for a concrete reporting API.
|
36
|
+
|
37
|
+
These abstractions are designed to be as modular and simple as possible:
|
38
|
+
|
39
|
+
* `BaseApiClient` - an interface for connecting to APIs.
|
40
|
+
* `BaseQuery` - encapsulates SQL-like request.
|
41
|
+
* `QuerySpecification` - parsed SQL-query into various elements.
|
42
|
+
* `BaseParser` - an interface to parse results from the API. Have a couple of default implementations:
|
43
|
+
* `ListParser` - returns results from API as a raw list.
|
44
|
+
* `DictParser` - returns results from API as a formatted dict.
|
45
|
+
* `NumericDictParser` - returns results from API as a formatted dict with converted numeric values.
|
46
|
+
* `GarfReport` - contains data from API in a format that is easy to write and interact with.
|
47
|
+
* `ApiReportFetcher` - responsible for fetching and parsing data from reporting API.
|
48
|
+
|
49
|
+
## Installation
|
50
|
+
|
51
|
+
`pip install garf-core`
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# garf-core - Unified approach for interacting with reporting APIs.
|
2
|
+
|
3
|
+
[](https://pypi.org/project/garf-core)
|
4
|
+
[](https://pypi.org/project/garf-core/)
|
5
|
+
|
6
|
+
|
7
|
+
`garf-core` contains the base abstractions are used by an implementation for a concrete reporting API.
|
8
|
+
|
9
|
+
These abstractions are designed to be as modular and simple as possible:
|
10
|
+
|
11
|
+
* `BaseApiClient` - an interface for connecting to APIs.
|
12
|
+
* `BaseQuery` - encapsulates SQL-like request.
|
13
|
+
* `QuerySpecification` - parsed SQL-query into various elements.
|
14
|
+
* `BaseParser` - an interface to parse results from the API. Have a couple of default implementations:
|
15
|
+
* `ListParser` - returns results from API as a raw list.
|
16
|
+
* `DictParser` - returns results from API as a formatted dict.
|
17
|
+
* `NumericDictParser` - returns results from API as a formatted dict with converted numeric values.
|
18
|
+
* `GarfReport` - contains data from API in a format that is easy to write and interact with.
|
19
|
+
* `ApiReportFetcher` - responsible for fetching and parsing data from reporting API.
|
20
|
+
|
21
|
+
## Installation
|
22
|
+
|
23
|
+
`pip install garf-core`
|
@@ -183,6 +183,18 @@ class GarfReport:
|
|
183
183
|
output[key] = value
|
184
184
|
return output
|
185
185
|
|
186
|
+
def to_polars(self) -> 'pl.DataFrame':
|
187
|
+
try:
|
188
|
+
import polars as pl
|
189
|
+
except ImportError as e:
|
190
|
+
raise ImportError(
|
191
|
+
'Please install garf-io with Polars support '
|
192
|
+
'- `pip install garf-io[polars]`'
|
193
|
+
) from e
|
194
|
+
return pl.DataFrame(
|
195
|
+
data=self.results, schema=self.column_names, orient='row'
|
196
|
+
)
|
197
|
+
|
186
198
|
def to_pandas(self) -> 'pd.DataFrame':
|
187
199
|
"""Converts report to Pandas dataframe.
|
188
200
|
|
@@ -196,8 +208,8 @@ class GarfReport:
|
|
196
208
|
import pandas as pd
|
197
209
|
except ImportError as e:
|
198
210
|
raise ImportError(
|
199
|
-
'Please install
|
200
|
-
'- `pip install
|
211
|
+
'Please install garf-io with Pandas support '
|
212
|
+
'- `pip install garf-io[pandas]`'
|
201
213
|
) from e
|
202
214
|
return pd.DataFrame(data=self.results, columns=self.column_names)
|
203
215
|
|
@@ -385,6 +397,30 @@ class GarfReport:
|
|
385
397
|
and other.results_placeholder,
|
386
398
|
)
|
387
399
|
|
400
|
+
@classmethod
|
401
|
+
def from_polars(cls, df: 'pl.DataFrame') -> GarfReport:
|
402
|
+
"""Builds GarfReport from polars dataframe.
|
403
|
+
|
404
|
+
Args:
|
405
|
+
df: Polars dataframe to build report from.
|
406
|
+
|
407
|
+
Returns:
|
408
|
+
Report build from dataframe data and columns.
|
409
|
+
|
410
|
+
Raises:
|
411
|
+
ImportError: If polars library not installed.
|
412
|
+
"""
|
413
|
+
try:
|
414
|
+
import polars as pl
|
415
|
+
except ImportError as e:
|
416
|
+
raise ImportError(
|
417
|
+
'Please install garf-io with Polars support '
|
418
|
+
'- `pip install garf-io[polars]`'
|
419
|
+
) from e
|
420
|
+
return cls(
|
421
|
+
results=df.to_numpy().tolist(), column_names=list(df.schema.keys())
|
422
|
+
)
|
423
|
+
|
388
424
|
@classmethod
|
389
425
|
def from_pandas(cls, df: 'pd.DataFrame') -> GarfReport:
|
390
426
|
"""Builds GarfReport from pandas dataframe.
|
@@ -402,8 +438,8 @@ class GarfReport:
|
|
402
438
|
import pandas as pd
|
403
439
|
except ImportError as e:
|
404
440
|
raise ImportError(
|
405
|
-
'Please install
|
406
|
-
'- `pip install
|
441
|
+
'Please install garf-io with Pandas support '
|
442
|
+
'- `pip install garf-io[pandas]`'
|
407
443
|
) from e
|
408
444
|
return cls(results=df.values.tolist(), column_names=list(df.columns.values))
|
409
445
|
|
@@ -11,9 +11,9 @@
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
12
|
# See the License for the specific language governing permissions and
|
13
13
|
# limitations under the License.
|
14
|
-
"""Module for getting data from
|
14
|
+
"""Module for getting data from API based on a query.
|
15
15
|
|
16
|
-
|
16
|
+
ApiReportFetcher performs fetching data from API, parsing it
|
17
17
|
and returning GarfReport.
|
18
18
|
"""
|
19
19
|
# pylint: disable=C0330, g-bad-import-order, g-multiple-import
|
@@ -34,10 +34,10 @@ logger = logging.getLogger(__name__)
|
|
34
34
|
|
35
35
|
|
36
36
|
class ApiReportFetcher:
|
37
|
-
"""Class responsible for getting data from
|
37
|
+
"""Class responsible for getting data from report API.
|
38
38
|
|
39
39
|
Attributes:
|
40
|
-
api_client: a client used for connecting to
|
40
|
+
api_client: a client used for connecting to API.
|
41
41
|
"""
|
42
42
|
|
43
43
|
def __init__(
|
@@ -45,10 +45,10 @@ class ApiReportFetcher:
|
|
45
45
|
api_client: api_clients.BaseApiClient,
|
46
46
|
parser: parsers.BaseParser = parsers.ListParser,
|
47
47
|
) -> None:
|
48
|
-
"""Instantiates
|
48
|
+
"""Instantiates ApiReportFetcher based on provided api client.
|
49
49
|
|
50
50
|
Args:
|
51
|
-
api_client: Instantiated
|
51
|
+
api_client: Instantiated api client.
|
52
52
|
parser: Parser.
|
53
53
|
"""
|
54
54
|
self.api_client = api_client
|
@@ -60,10 +60,10 @@ class ApiReportFetcher:
|
|
60
60
|
args: dict[str, Any] | None = None,
|
61
61
|
**kwargs: str,
|
62
62
|
) -> report.GarfReport:
|
63
|
-
"""Asynchronously fetches data from
|
63
|
+
"""Asynchronously fetches data from API based on query_specification.
|
64
64
|
|
65
65
|
Args:
|
66
|
-
query_specification: Query text that will be passed to
|
66
|
+
query_specification: Query text that will be passed to API
|
67
67
|
alongside column_names, customizers and virtual columns.
|
68
68
|
args: Arguments that need to be passed to the query.
|
69
69
|
|
@@ -78,10 +78,10 @@ class ApiReportFetcher:
|
|
78
78
|
args: dict[str, Any] | None = None,
|
79
79
|
**kwargs: str,
|
80
80
|
) -> report.GarfReport:
|
81
|
-
"""Fetches data from
|
81
|
+
"""Fetches data from API based on query_specification.
|
82
82
|
|
83
83
|
Args:
|
84
|
-
query_specification: Query text that will be passed to
|
84
|
+
query_specification: Query text that will be passed to API
|
85
85
|
alongside column_names, customizers and virtual columns.
|
86
86
|
args: Arguments that need to be passed to the query.
|
87
87
|
|
@@ -90,7 +90,7 @@ class ApiReportFetcher:
|
|
90
90
|
|
91
91
|
Raises:
|
92
92
|
GarfExecutorException:
|
93
|
-
When customer_ids are not provided or
|
93
|
+
When customer_ids are not provided or API returned error.
|
94
94
|
"""
|
95
95
|
if not isinstance(query_specification, query_editor.QuerySpecification):
|
96
96
|
query_specification = query_editor.QuerySpecification(
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: garf-core
|
3
|
+
Version: 0.0.6
|
4
|
+
Summary: Abstracts fetching data from API based on provided SQL-like query.
|
5
|
+
Author-email: "Google Inc. (gTech gPS CSE team)" <no-reply@google.com>
|
6
|
+
License: Apache 2.0
|
7
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
8
|
+
Classifier: Programming Language :: Python :: 3.8
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
13
|
+
Classifier: Intended Audience :: Developers
|
14
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
15
|
+
Classifier: Operating System :: OS Independent
|
16
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
17
|
+
Requires-Python: >=3.8
|
18
|
+
Description-Content-Type: text/markdown
|
19
|
+
Requires-Dist: python-dateutil
|
20
|
+
Requires-Dist: jinja2==3.1.4
|
21
|
+
Requires-Dist: typing-extensions
|
22
|
+
Provides-Extra: pandas
|
23
|
+
Requires-Dist: pandas; extra == "pandas"
|
24
|
+
Provides-Extra: polars
|
25
|
+
Requires-Dist: polars; extra == "polars"
|
26
|
+
Provides-Extra: all
|
27
|
+
Requires-Dist: garf-core[pandas,polars]; extra == "all"
|
28
|
+
|
29
|
+
# garf-core - Unified approach for interacting with reporting APIs.
|
30
|
+
|
31
|
+
[](https://pypi.org/project/garf-core)
|
32
|
+
[](https://pypi.org/project/garf-core/)
|
33
|
+
|
34
|
+
|
35
|
+
`garf-core` contains the base abstractions are used by an implementation for a concrete reporting API.
|
36
|
+
|
37
|
+
These abstractions are designed to be as modular and simple as possible:
|
38
|
+
|
39
|
+
* `BaseApiClient` - an interface for connecting to APIs.
|
40
|
+
* `BaseQuery` - encapsulates SQL-like request.
|
41
|
+
* `QuerySpecification` - parsed SQL-query into various elements.
|
42
|
+
* `BaseParser` - an interface to parse results from the API. Have a couple of default implementations:
|
43
|
+
* `ListParser` - returns results from API as a raw list.
|
44
|
+
* `DictParser` - returns results from API as a formatted dict.
|
45
|
+
* `NumericDictParser` - returns results from API as a formatted dict with converted numeric values.
|
46
|
+
* `GarfReport` - contains data from API in a format that is easy to write and interact with.
|
47
|
+
* `ApiReportFetcher` - responsible for fetching and parsing data from reporting API.
|
48
|
+
|
49
|
+
## Installation
|
50
|
+
|
51
|
+
`pip install garf-core`
|
garf_core-0.0.5/PKG-INFO
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.2
|
2
|
-
Name: garf-core
|
3
|
-
Version: 0.0.5
|
4
|
-
Summary: Abstracts fetching data from API based on provided SQL-like query.
|
5
|
-
Author-email: "Google Inc. (gTech gPS CSE team)" <no-reply@google.com>
|
6
|
-
License: Apache 2.0
|
7
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
8
|
-
Classifier: Programming Language :: Python :: 3.8
|
9
|
-
Classifier: Programming Language :: Python :: 3.9
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
13
|
-
Classifier: Intended Audience :: Developers
|
14
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
15
|
-
Classifier: Operating System :: OS Independent
|
16
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
17
|
-
Requires-Python: >=3.8
|
18
|
-
Description-Content-Type: text/markdown
|
19
|
-
Requires-Dist: python-dateutil
|
20
|
-
Requires-Dist: jinja2==3.1.4
|
21
|
-
Requires-Dist: typing-extensions
|
22
|
-
Provides-Extra: pandas
|
23
|
-
Requires-Dist: pandas; extra == "pandas"
|
24
|
-
Provides-Extra: all
|
25
|
-
Requires-Dist: garf-core[pandas]; extra == "all"
|
26
|
-
|
27
|
-
# gaarf-core - Unified approach for interacting with reporting APIs.
|
garf_core-0.0.5/README.md
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# gaarf-core - Unified approach for interacting with reporting APIs.
|
@@ -1,27 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.2
|
2
|
-
Name: garf-core
|
3
|
-
Version: 0.0.5
|
4
|
-
Summary: Abstracts fetching data from API based on provided SQL-like query.
|
5
|
-
Author-email: "Google Inc. (gTech gPS CSE team)" <no-reply@google.com>
|
6
|
-
License: Apache 2.0
|
7
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
8
|
-
Classifier: Programming Language :: Python :: 3.8
|
9
|
-
Classifier: Programming Language :: Python :: 3.9
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
13
|
-
Classifier: Intended Audience :: Developers
|
14
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
15
|
-
Classifier: Operating System :: OS Independent
|
16
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
17
|
-
Requires-Python: >=3.8
|
18
|
-
Description-Content-Type: text/markdown
|
19
|
-
Requires-Dist: python-dateutil
|
20
|
-
Requires-Dist: jinja2==3.1.4
|
21
|
-
Requires-Dist: typing-extensions
|
22
|
-
Provides-Extra: pandas
|
23
|
-
Requires-Dist: pandas; extra == "pandas"
|
24
|
-
Provides-Extra: all
|
25
|
-
Requires-Dist: garf-core[pandas]; extra == "all"
|
26
|
-
|
27
|
-
# gaarf-core - Unified approach for interacting with reporting APIs.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|