Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Rodolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cubicweb
cubes
Rodolf
Commits
484aacc3a69b
Commit
484aacc3a69b
authored
1 year ago
by
Fabien Amarger
Browse files
Options
Downloads
Patches
Plain Diff
feat: Store import_data log into the import_report file
parent
e249808dc6cc
No related branches found
No related tags found
1 merge request
!16
Log import_data to S3 storage
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cubicweb_rodolf/import_data.py
+22
-2
22 additions, 2 deletions
cubicweb_rodolf/import_data.py
with
22 additions
and
2 deletions
cubicweb_rodolf/import_data.py
+
22
−
2
View file @
484aacc3
...
...
@@ -15,9 +15,10 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import
io
import
logging
import
requests
import
pyshacl
from
datetime
import
datetime
...
...
@@ -18,9 +19,10 @@
import
logging
import
requests
import
pyshacl
from
datetime
import
datetime
from
cubicweb
import
Binary
from
cubicweb_rq.rq
import
rqjob
from
rdflib
import
Graph
...
...
@@ -69,6 +71,14 @@
return
everything_ok
,
errors
def
get_import_data_logger
(
stream_file
):
log
=
logging
.
getLogger
(
"
rq.task
"
)
handler
=
logging
.
StreamHandler
(
stream_file
)
handler
.
setLevel
(
logging
.
DEBUG
)
log
.
addHandler
(
handler
)
return
log
@rqjob
def
import_data
(
cnx
,
...
...
@@ -84,6 +94,8 @@
import_process
=
cnx
.
entity_from_eid
(
import_process_eid
)
wf
=
import_process
.
cw_adapt_to
(
"
IWorkflowable
"
)
wf
.
fire_transition
(
"
starts
"
)
stream_log_file
=
io
.
StringIO
()
log
=
get_import_data_logger
(
stream_log_file
)
cnx
.
commit
()
task_failed
=
False
formatted_exc
=
None
...
...
@@ -87,7 +99,6 @@
cnx
.
commit
()
task_failed
=
False
formatted_exc
=
None
log
=
logging
.
getLogger
(
"
rq.task
"
)
import_recipe
=
import_process
.
import_recipe
[
0
]
dataservice
=
import_recipe
.
dataservice
[
0
]
import_procedure
=
import_process
.
import_procedure
[
0
]
...
...
@@ -111,7 +122,16 @@
task_failed
=
True
else
:
log
.
info
(
"
Data was successfully validated
"
)
# XXX PUT in S3 file
import_process
.
cw_set
(
import_report
=
cnx
.
create_entity
(
"
File
"
,
title
=
f
"
Log file for ImportProcess#
{
import_process_eid
}
"
,
data
=
Binary
(
stream_log_file
.
read
().
encode
(
"
utf8
"
)),
data_name
=
"
log.txt
"
,
data_format
=
"
plain/text
"
,
)
)
except
Exception
as
error
:
task_failed
=
True
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment