-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow processors to log and spew objects larger than 64K
- Loading branch information
Showing
9 changed files
with
173 additions
and
5 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 |
---|---|---|
|
@@ -8,7 +8,6 @@ __pycache__/ | |
|
||
# Distribution / packaging | ||
.Python | ||
env/ | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
|
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 @@ | ||
import collections | ||
|
||
from datapackage_pipelines.wrapper import ingest, spew | ||
|
||
params, dp, res_iter = ingest() | ||
|
||
|
||
def sink(res_iter_): | ||
for res in res_iter_: | ||
collections.deque(res, maxlen=0) | ||
yield [] | ||
|
||
spew(dp, sink(res_iter)) |
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,5 @@ | ||
from datapackage_pipelines.wrapper import ingest, spew | ||
|
||
params, datapackage, res_iter = ingest() | ||
datapackage['profile'] = 'tabular-data-package' | ||
spew(datapackage, res_iter) |
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,26 @@ | ||
import logging | ||
import itertools | ||
import os | ||
|
||
from datapackage_pipelines.wrapper import ingest, spew | ||
|
||
params, dp, res_iter = ingest() | ||
|
||
big_string = 'z'*64*1024 | ||
|
||
logging.info('Look at me %s', big_string) | ||
|
||
dp['name'] = 'a' | ||
dp['resources'].append({ | ||
'name': 'aa%f' % os.getpid(), | ||
'path': 'data/bla.csv', | ||
'schema': { | ||
'fields': [ | ||
{'name': 'a', 'type': 'string'} | ||
] | ||
} | ||
}) | ||
|
||
res = iter([{'a': big_string}]) | ||
|
||
spew(dp, itertools.chain(res_iter, [res])) |
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,68 @@ | ||
pipeline-test-basic: | ||
pipeline: | ||
- | ||
run: add_metadata | ||
parameters: | ||
name: 'al-treasury-spending' | ||
title: 'Albania Treasury Service' | ||
granularity: transactional | ||
countryCode: AL | ||
homepage: 'http://spending.data.al/en/treasuryservice/list/year/2014/inst_code/1005001' | ||
- | ||
run: add_resource | ||
parameters: | ||
name: "treasury" | ||
url: "https://raw.githubusercontent.com/openspending/fiscal-data-package-demos/master/al-treasury-spending/data/treasury.csv" | ||
schema: | ||
fields: | ||
- | ||
name: "Budget Institution" | ||
type: string | ||
- | ||
name: "Supplier" | ||
type: string | ||
- | ||
name: "Treasury Branch" | ||
type: string | ||
- | ||
name: "Value" | ||
type: number | ||
- | ||
name: "Date registered" | ||
type: date | ||
- | ||
name: "Date executed" | ||
type: date | ||
- | ||
name: "Receipt No" | ||
type: string | ||
- | ||
name: "Kategori Shpenzimi" | ||
type: string | ||
- | ||
name: "Receipt Description" | ||
type: string | ||
- | ||
run: stream_remote_resources | ||
- | ||
run: pipeline-test-supplier-titleize | ||
parameters: | ||
key: Supplier | ||
- | ||
run: ..extract-year | ||
parameters: | ||
from-key: "Date executed" | ||
to-key: "Year" | ||
- | ||
run: ..common.pipeline-common | ||
- | ||
run: dump.to_zip | ||
parameters: | ||
out-file: dump.zip | ||
|
||
|
||
pipeline-test-big-outputs: | ||
pipeline: | ||
- run: big-outputs | ||
- run: big-outputs | ||
|
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,17 @@ | ||
from datapackage_pipelines.wrapper import ingest, spew | ||
|
||
params, datapackage, res_iter = ingest() | ||
|
||
key = params['key'] | ||
|
||
|
||
def process_resources(_res_iter): | ||
for res in _res_iter: | ||
def process_res(_res): | ||
for line in _res: | ||
if key in line: | ||
line[key] = line[key].title() | ||
yield line | ||
yield process_res(res) | ||
|
||
spew(datapackage, process_resources(res_iter)) |
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,27 @@ | ||
from datapackage_pipelines.wrapper import ingest, spew | ||
|
||
params, datapackage, res_iter = ingest() | ||
|
||
from_key = params['from-key'] | ||
to_key = params['to-key'] | ||
|
||
|
||
def process_resources(_res_iter): | ||
for res in _res_iter: | ||
def process_res(_res): | ||
for line in _res: | ||
if from_key in line: | ||
line[to_key] = line[from_key].year | ||
yield line | ||
yield process_res(res) | ||
|
||
|
||
for resource in datapackage['resources']: | ||
if len(list(filter(lambda field: field['name'] == from_key, resource.get('schema',{}).get('fields',[])))) > 0: | ||
resource['schema']['fields'].append({ | ||
'name': to_key, | ||
'osType': 'date:fiscal-year', | ||
'type': 'integer' | ||
}) | ||
|
||
spew(datapackage, process_resources(res_iter)) |
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