-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from simonwoerpel/develop
0.1.2
- Loading branch information
Showing
24 changed files
with
262 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[bumpversion] | ||
current_version = 0.1.2 | ||
tag_name = {new_version} | ||
commit = True | ||
tag = True | ||
|
||
[bumpversion:file:setup.py] | ||
search = version='{current_version}' | ||
replace = version='{new_version}' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# changelog | ||
|
||
## 0.1.2 | ||
|
||
- Add pagination by offset logic | ||
- Allow lambda functions as strings in yaml for column transformation and df operations | ||
- Add option in yaml to set cache header for google cloud storage blobs | ||
- Small bugfixes | ||
|
||
|
||
## 0.1.1 | ||
|
||
- first release with basic functionality |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
storage: | ||
filesystem: | ||
enabled: true | ||
data_root: datastore-testdata/example | ||
datasets: | ||
rki_json: | ||
json_url: https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?where=1%3D1&outFields=*&outSR=4326&f=json | ||
json_normalize: | ||
record_path: features | ||
paginate: | ||
offset: | ||
param: resultOffset | ||
get_offset_value: 'lambda res: len(res.json()["features"])' | ||
columns: | ||
- date: attributes.Meldedatum | ||
- last_updated: attributes.Datenstand | ||
- report_id: attributes.ObjectId | ||
- gender: attributes.Geschlecht | ||
- age: attributes.Altersgruppe | ||
- value: attributes.AnzahlFall | ||
- death_value: attributes.AnzahlTodesfall | ||
- new_case: attributes.NeuerFall | ||
- new_death_case: attributes.NeuerTodesfall | ||
- state_id: attributes.IdBundesland | ||
- state: attributes.Bundesland | ||
- district_id: attributes.IdLandkreis | ||
- district: attributes.Landkreis | ||
incremental: true | ||
dt_index: | ||
column: date |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,36 @@ | ||
import banal | ||
|
||
from .exceptions import ConfigError | ||
from .util import safe_eval | ||
|
||
|
||
def wrangle_columns(df, config): | ||
use_columns = [] | ||
rename_columns = {} | ||
map_funcs = {} | ||
for column in config.columns: | ||
if isinstance(column, str): | ||
use_columns.append(column) | ||
elif isinstance(column, dict): | ||
elif banal.is_mapping(column): | ||
if len(column) > 1: | ||
raise ConfigError(f'Column config `{column}` has errors.') | ||
target, source = list(column.items())[0] | ||
use_columns.append(source) | ||
rename_columns[source] = target | ||
if banal.is_mapping(source): | ||
source_column = source.get('column', target) | ||
map_func = source.get('map') | ||
if map_func: | ||
map_funcs[target] = safe_eval(map_func) | ||
else: | ||
source_column = source | ||
use_columns.append(source_column) | ||
rename_columns[source_column] = target | ||
else: | ||
raise ConfigError(f'Column config `{column}` has errors.') | ||
|
||
df = df[use_columns] | ||
if rename_columns: | ||
df = df.rename(columns=rename_columns) | ||
if map_funcs: | ||
for col, func in map_funcs.items(): | ||
df[col] = df[col].map(func) | ||
return df |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from .exceptions import ConfigError | ||
from .util import ensure_singlekey_dict, safe_eval | ||
|
||
|
||
def paginate_offset(get_request, offset_param, get_offset_value, offset=0): | ||
res = get_request(**{offset_param: offset}) | ||
new_offset = offset + get_offset_value(res) | ||
if new_offset > offset: | ||
yield res | ||
yield from paginate_offset(get_request, offset_param, get_offset_value, new_offset) | ||
|
||
|
||
def paginate(get_request, config): | ||
method, config = ensure_singlekey_dict(config) | ||
if method is None: | ||
raise ConfigError(f'Please make sure {config} is properly configured as single-key dict!') | ||
if method != 'offset': | ||
raise ConfigError(f'Other pagination method than `{method}` currently not registered') | ||
yield from paginate_offset(get_request, config['param'], safe_eval(config['get_offset_value'])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.