Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Boxiang Sun
wendelin
Commits
cbafa3d9
Commit
cbafa3d9
authored
Apr 24, 2020
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove try except block which just logs as we get logging anyway when exception happens.
parent
5c133e82
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
114 deletions
+110
-114
bt5/erp5_wendelin_data_lake_ingestion/SkinTemplateItem/portal_skins/erp5_wendelin_data_lake/IngestionPolicy_getIngestionOperationAndParameterDictEbulk.py
...stionPolicy_getIngestionOperationAndParameterDictEbulk.py
+110
-114
No files found.
bt5/erp5_wendelin_data_lake_ingestion/SkinTemplateItem/portal_skins/erp5_wendelin_data_lake/IngestionPolicy_getIngestionOperationAndParameterDictEbulk.py
View file @
cbafa3d9
...
@@ -10,37 +10,36 @@ reference_separator = portal.getIngestionReferenceDictionary()["reference_separa
...
@@ -10,37 +10,36 @@ reference_separator = portal.getIngestionReferenceDictionary()["reference_separa
reference_end_single
=
portal
.
getIngestionReferenceDictionary
()[
"single_end_suffix"
]
reference_end_single
=
portal
.
getIngestionReferenceDictionary
()[
"single_end_suffix"
]
none_extension
=
portal
.
getIngestionReferenceDictionary
()[
"none_extension"
]
none_extension
=
portal
.
getIngestionReferenceDictionary
()[
"none_extension"
]
try
:
# remove supplier, eof, size and hash from reference
# remove supplier, eof, size and hash from reference
reference
=
reference_separator
.
join
(
reference
.
split
(
reference_separator
)[
1
:
-
3
])
reference
=
reference_separator
.
join
(
reference
.
split
(
reference_separator
)[
1
:
-
3
])
data_ingestion_reference
=
reference
data_ingestion_reference
=
reference
eof
=
movement_dict
.
get
(
'eof'
,
reference_end_single
)
if
movement_dict
.
get
(
'eof'
,
reference_end_single
)
!=
""
else
reference_end_single
eof
=
movement_dict
.
get
(
'eof'
,
reference_end_single
)
if
movement_dict
.
get
(
'eof'
,
reference_end_single
)
!=
""
else
reference_end_single
resource_reference
=
movement_dict
.
get
(
'resource_reference'
,
None
)
resource_reference
=
movement_dict
.
get
(
'resource_reference'
,
None
)
supplier
=
movement_dict
.
get
(
'supplier'
,
None
)
supplier
=
movement_dict
.
get
(
'supplier'
,
None
)
extension
=
movement_dict
.
get
(
'extension'
,
None
)
extension
=
movement_dict
.
get
(
'extension'
,
None
)
dataset_reference
=
movement_dict
.
get
(
'dataset_reference'
,
None
)
dataset_reference
=
movement_dict
.
get
(
'dataset_reference'
,
None
)
data_ingestion_id
=
'%s_%s_%s_%s'
%
(
supplier
,
dataset_reference
,
now_string
,
eof
)
data_ingestion_id
=
'%s_%s_%s_%s'
%
(
supplier
,
dataset_reference
,
now_string
,
eof
)
size
=
movement_dict
.
get
(
'size'
,
None
)
if
movement_dict
.
get
(
'size'
,
None
)
!=
""
else
None
size
=
movement_dict
.
get
(
'size'
,
None
)
if
movement_dict
.
get
(
'size'
,
None
)
!=
""
else
None
hash_value
=
movement_dict
.
get
(
'hash'
,
None
)
if
movement_dict
.
get
(
'hash'
,
None
)
!=
""
else
None
hash_value
=
movement_dict
.
get
(
'hash'
,
None
)
if
movement_dict
.
get
(
'hash'
,
None
)
!=
""
else
None
# search for applicable data ingestion
# search for applicable data ingestion
data_ingestion
=
portal_catalog
.
getResultValue
(
data_ingestion
=
portal_catalog
.
getResultValue
(
portal_type
=
'Data Ingestion'
,
portal_type
=
'Data Ingestion'
,
reference
=
data_ingestion_reference
)
reference
=
data_ingestion_reference
)
if
data_ingestion
is
not
None
:
if
data_ingestion
is
not
None
:
if
data_ingestion
.
getSimulationState
()
!=
'started'
:
if
data_ingestion
.
getSimulationState
()
!=
'started'
:
if
eof
==
reference_end_single
:
# if not split (one single ingestion), invalidate old ingestion
if
eof
==
reference_end_single
:
# if not split (one single ingestion), invalidate old ingestion
portal
.
ERP5Site_invalidateIngestionObjects
(
data_ingestion_reference
)
portal
.
ERP5Site_invalidateIngestionObjects
(
data_ingestion_reference
)
specialise_value_list
=
[
x
.
getObject
()
for
x
in
portal_catalog
.
searchResults
(
specialise_value_list
=
[
x
.
getObject
()
for
x
in
portal_catalog
.
searchResults
(
portal_type
=
'Data Supply'
,
portal_type
=
'Data Supply'
,
reference
=
'embulk'
,
reference
=
'embulk'
,
validation_state
=
'validated'
)]
validation_state
=
'validated'
)]
# create a new data ingestion
# create a new data ingestion
data_ingestion
=
portal
.
data_ingestion_module
.
newContent
(
data_ingestion
=
portal
.
data_ingestion_module
.
newContent
(
id
=
data_ingestion_id
,
id
=
data_ingestion_id
,
portal_type
=
"Data Ingestion"
,
portal_type
=
"Data Ingestion"
,
title
=
movement_dict
.
get
(
'filename'
,
data_ingestion_reference
),
title
=
movement_dict
.
get
(
'filename'
,
data_ingestion_reference
),
...
@@ -48,7 +47,7 @@ try:
...
@@ -48,7 +47,7 @@ try:
start_date
=
now
,
start_date
=
now
,
specialise_value_list
=
specialise_value_list
)
specialise_value_list
=
specialise_value_list
)
property_list
=
[
"title"
,
property_list
=
[
"title"
,
"source"
,
"source"
,
"source_section"
,
"source_section"
,
"source_project"
,
"source_project"
,
...
@@ -57,14 +56,14 @@ try:
...
@@ -57,14 +56,14 @@ try:
"destination_project"
,
"destination_project"
,
"specialise"
]
"specialise"
]
composed
=
data_ingestion
.
asComposedDocument
()
composed
=
data_ingestion
.
asComposedDocument
()
data_ingestion
.
edit
(
**
{
p
:
composed
.
getProperty
(
p
)
for
p
in
property_list
})
data_ingestion
.
edit
(
**
{
p
:
composed
.
getProperty
(
p
)
for
p
in
property_list
})
# create ingestion lines from specialise lines and assign input line
# create ingestion lines from specialise lines and assign input line
# and operation line
# and operation line
input_line
=
None
input_line
=
None
operation_line
=
None
operation_line
=
None
for
supply_line
in
composed
.
objectValues
(
portal_type
=
'Data Supply Line'
):
for
supply_line
in
composed
.
objectValues
(
portal_type
=
'Data Supply Line'
):
current_line
=
data_ingestion
.
newContent
(
current_line
=
data_ingestion
.
newContent
(
portal_type
=
"Data Ingestion Line"
,
portal_type
=
"Data Ingestion Line"
,
title
=
supply_line
.
getTitle
(),
title
=
supply_line
.
getTitle
(),
...
@@ -82,22 +81,22 @@ try:
...
@@ -82,22 +81,22 @@ try:
# we set quantity=0 for the empty line
# we set quantity=0 for the empty line
current_line
.
setQuantity
(
0
)
current_line
.
setQuantity
(
0
)
# copy device and configuration from operation line to input line
# copy device and configuration from operation line to input line
input_line
.
setAggregateSet
(
input_line
.
setAggregateSet
(
input_line
.
getAggregateList
()
+
operation_line
.
getAggregateList
())
input_line
.
getAggregateList
()
+
operation_line
.
getAggregateList
())
if
hash_value
is
None
or
eof
!=
reference_end_single
:
# do not set hash if split, calculate when append
if
hash_value
is
None
or
eof
!=
reference_end_single
:
# do not set hash if split, calculate when append
hash_value
=
""
hash_value
=
""
data_stream
=
portal
.
data_stream_module
.
newContent
(
data_stream
=
portal
.
data_stream_module
.
newContent
(
portal_type
=
"Data Stream"
,
portal_type
=
"Data Stream"
,
id
=
data_ingestion_id
,
id
=
data_ingestion_id
,
version
=
hash_value
,
version
=
hash_value
,
title
=
"%s%s"
%
(
data_ingestion
.
getTitle
(),
"."
+
extension
if
extension
!=
none_extension
else
""
),
title
=
"%s%s"
%
(
data_ingestion
.
getTitle
(),
"."
+
extension
if
extension
!=
none_extension
else
""
),
reference
=
data_ingestion_reference
)
reference
=
data_ingestion_reference
)
input_line
.
setDefaultAggregateValue
(
data_stream
)
input_line
.
setDefaultAggregateValue
(
data_stream
)
if
dataset_reference
is
not
None
:
if
dataset_reference
is
not
None
:
data_set
=
portal
.
data_set_module
.
get
(
dataset_reference
)
data_set
=
portal
.
data_set_module
.
get
(
dataset_reference
)
try
:
try
:
if
data_set
is
None
:
if
data_set
is
None
:
...
@@ -118,15 +117,12 @@ try:
...
@@ -118,15 +117,12 @@ try:
data_set
.
validate
()
data_set
.
validate
()
input_line
.
setDefaultAggregateValue
(
data_set
)
input_line
.
setDefaultAggregateValue
(
data_set
)
data_ingestion
.
start
()
data_ingestion
.
start
()
data_operation
=
operation_line
.
getResourceValue
()
data_operation
=
operation_line
.
getResourceValue
()
data_stream
=
input_line
.
getAggregateDataStreamValue
()
data_stream
=
input_line
.
getAggregateDataStreamValue
()
if
eof
==
reference_end_single
:
if
eof
==
reference_end_single
:
data_stream
.
validate
()
data_stream
.
validate
()
return
data_operation
,
{
'data_stream'
:
data_stream
}
return
data_operation
,
{
'data_stream'
:
data_stream
}
except
Exception
as
e
:
context
.
logEntry
(
''
.
join
([
"[ERROR] Error during ingestion policy operation: "
,
str
(
e
)]))
raise
e
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