EOX GitLab Instance
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
View Server 2
harvester
Commits
6ea2d918
Commit
6ea2d918
authored
Dec 09, 2021
by
Nikola Jankovic
💻
Browse files
Merge branch 'postprocess' into 'main'
Postprocessing See merge request
!6
parents
26b364eb
1dee370c
Pipeline
#19507
passed with stages
in 1 minute and 58 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
harvester/harvester.py
View file @
6ea2d918
...
...
@@ -10,7 +10,7 @@ from .endpoint import get_endpoint
from
.source
import
get_source
from
.exceptions
import
HarvestError
from
.utils
import
cql_filter
from
.postprocess
import
get_postprocessor
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -52,6 +52,13 @@ def main(config: dict, value: str, client: Redis):
# Perform harvest
result
=
resource
.
harvest
()
if
"postprocess"
in
harvest_config
:
postprocessor
=
get_postprocessor
(
harvest_config
[
"postprocess"
])
result
=
(
postprocessor
.
postprocess
(
item
)
for
item
in
result
)
# Filter data
result
=
cql_filter
(
harvest_config
[
"filter"
],
result
)
...
...
harvester/postprocess.py
0 → 100644
View file @
6ea2d918
from
abc
import
ABC
,
abstractmethod
from
typing
import
Dict
,
Type
class
Postprocessor
(
ABC
):
def
__init__
(
self
,
**
kwargs
):
...
@
abstractmethod
def
postprocess
(
self
,
item
:
dict
)
->
dict
:
pass
POSTPROCESSORS
:
Dict
[
str
,
Type
[
Postprocessor
]]
=
{
}
def
get_postprocessor
(
config
:
dict
)
->
Postprocessor
:
cls
=
POSTPROCESSORS
[
config
.
pop
(
"type"
)]
return
cls
(
**
config
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment