Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
django-diu
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hervé MENAGER
django-diu
Commits
3c6af9a6
Commit
3c6af9a6
authored
6 years ago
by
Hervé MENAGER
Browse files
Options
Downloads
Patches
Plain Diff
fix progress bar in dataframe processing
parent
9718eaea
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
django_diu/import_command.py
+7
-7
7 additions, 7 deletions
django_diu/import_command.py
with
7 additions
and
7 deletions
django_diu/import_command.py
+
7
−
7
View file @
3c6af9a6
...
...
@@ -73,8 +73,8 @@ class ImportTask(object):
def
post_process
(
self
):
pass
def
_process_rows
(
self
,
rows
):
for
idx
,
row
in
enumerate
(
rows
)
:
def
_process_rows
(
self
,
rows
,
progress
=
None
):
for
row
in
rows
:
try
:
new_object
=
None
with
transaction
.
atomic
():
...
...
@@ -93,8 +93,8 @@ class ImportTask(object):
if
self
.
progress_bar
==
False
:
self
.
out_stream
.
write
(
self
.
style
.
SUCCESS
(
'
Successfully inserted {}
'
.
format
(
new_object
)))
if
self
.
progress_bar
:
self
.
row
s
.
update
(
idx
)
if
self
.
progress_bar
==
True
:
progres
s
.
update
(
1
)
def
count_source
(
self
):
self
.
source_count
=
len
(
self
.
rows
)
...
...
@@ -104,8 +104,8 @@ class ImportTask(object):
self
.
count_source
()
if
self
.
progress_bar
is
True
:
with
click
.
progressbar
(
length
=
self
.
source_count
,
label
=
'
Importing
'
+
self
.
description
+
'
(
'
+
str
(
self
.
source_count
)
+
'
rows to process).
'
)
as
ro
ws_list
:
self
.
_process_rows
(
rows_list
)
label
=
'
Importing
'
+
self
.
description
+
'
(
'
+
str
(
self
.
source_count
)
+
'
rows to process).
'
)
as
p
ro
gress
:
self
.
_process_rows
(
self
.
rows
,
progress
)
else
:
self
.
_process_rows
(
self
.
rows
)
self
.
post_process
()
...
...
@@ -152,7 +152,7 @@ class DataFrameImportTask(ImportTask):
dataframe
=
None
def
open_data_source
(
self
):
self
.
rows
=
self
.
dataframe
.
iterrows
()
self
.
rows
=
(
row
for
idx
,
row
in
self
.
dataframe
.
iterrows
()
)
def
count_source
(
self
):
self
.
source_count
=
self
.
dataframe
.
shape
[
0
]
...
...
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