Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
iamap
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
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
AMAP
iamap
Commits
5277db65
Commit
5277db65
authored
7 months ago
by
paul.tresson_ird.fr
Browse files
Options
Downloads
Patches
Plain Diff
remove temporary files at a given frequency. could maybe fix #10 ?
parent
d91acd43
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
encoder.py
+34
-2
34 additions, 2 deletions
encoder.py
with
34 additions
and
2 deletions
encoder.py
+
34
−
2
View file @
5277db65
...
@@ -81,6 +81,7 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
...
@@ -81,6 +81,7 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
WORKERS
=
'
WORKERS
'
WORKERS
=
'
WORKERS
'
PAUSES
=
'
PAUSES
'
PAUSES
=
'
PAUSES
'
REMOVE_TEMP_FILES
=
'
REMOVE_TEMP_FILES
'
REMOVE_TEMP_FILES
=
'
REMOVE_TEMP_FILES
'
TEMP_FILES_CLEANUP_FREQ
=
'
TEMP_FILES_CLEANUP_FREQ
'
def
initAlgorithm
(
self
,
config
=
None
):
def
initAlgorithm
(
self
,
config
=
None
):
...
@@ -155,6 +156,16 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
...
@@ -155,6 +156,16 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
maxValue
=
10000
maxValue
=
10000
)
)
tmp_files_cleanup_frq
=
QgsProcessingParameterNumber
(
name
=
self
.
TEMP_FILES_CLEANUP_FREQ
,
description
=
self
.
tr
(
'
Frequencie at which temporary files should be cleaned up (zero means no cleanup).
'
),
type
=
QgsProcessingParameterNumber
.
Integer
,
defaultValue
=
1000
,
minValue
=
1
,
maxValue
=
10000
)
remove_tmp_files
=
QgsProcessingParameterBoolean
(
remove_tmp_files
=
QgsProcessingParameterBoolean
(
name
=
self
.
REMOVE_TEMP_FILES
,
name
=
self
.
REMOVE_TEMP_FILES
,
description
=
self
.
tr
(
description
=
self
.
tr
(
...
@@ -304,7 +315,8 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
...
@@ -304,7 +315,8 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
merge_param
,
merge_param
,
nworkers_param
,
nworkers_param
,
pauses_param
,
pauses_param
,
remove_tmp_files
remove_tmp_files
,
tmp_files_cleanup_frq
,
):
):
param
.
setFlags
(
param
.
setFlags
(
param
.
flags
()
|
QgsProcessingParameterDefinition
.
FlagAdvanced
)
param
.
flags
()
|
QgsProcessingParameterDefinition
.
FlagAdvanced
)
...
@@ -515,7 +527,6 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
...
@@ -515,7 +527,6 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
self
.
tr
(
f
"
\n
!!! only
{
free_space
}
GB disk space remaining, canceling !!!
\n
"
))
self
.
tr
(
f
"
\n
!!! only
{
free_space
}
GB disk space remaining, canceling !!!
\n
"
))
break
break
bboxes
.
extend
(
sample
[
'
bbox
'
])
bboxes
.
extend
(
sample
[
'
bbox
'
])
if
self
.
pauses
!=
0
:
if
self
.
pauses
!=
0
:
...
@@ -547,6 +558,25 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
...
@@ -547,6 +558,25 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
time_remain_h
,
time_remain_m
=
divmod
(
time_remain_m
,
60
)
time_remain_h
,
time_remain_m
=
divmod
(
time_remain_m
,
60
)
feedback
.
pushInfo
(
f
"
Estimated time remaining:
{
time_remain_h
:
d
}
h:
{
time_remain_m
:
02
d
}
m:
{
time_remain_s
:
02
d
}
s
\n
"
)
feedback
.
pushInfo
(
f
"
Estimated time remaining:
{
time_remain_h
:
d
}
h:
{
time_remain_m
:
02
d
}
m:
{
time_remain_s
:
02
d
}
s
\n
"
)
if
((
current
+
1
)
%
self
.
cleanup_frq
==
0
)
and
self
.
remove_tmp_files
:
## not the cleanest way to do for now
## but avoids to refactor all
self
.
all_encoding_done
=
False
feedback
.
pushInfo
(
'
Cleaning temporary files...
'
)
all_tiles
=
[
os
.
path
.
join
(
self
.
output_subdir
,
f
)
for
f
in
os
.
listdir
(
self
.
output_subdir
)
if
f
.
endswith
(
'
_tmp.tif
'
)]
all_tiles
=
[
f
for
f
in
all_tiles
if
not
f
.
startswith
(
'
merged
'
)]
dst_path
=
Path
(
os
.
path
.
join
(
self
.
output_subdir
,
'
merged_tmp.tif
'
))
merge_tiles
(
tiles
=
all_tiles
,
dst_path
=
dst_path
,
method
=
self
.
merge_method
,
)
self
.
remove_temp_files
()
self
.
all_encoding_done
=
True
# Update the progress bar
# Update the progress bar
feedback
.
setProgress
(
int
((
current
+
1
)
*
total
))
feedback
.
setProgress
(
int
((
current
+
1
)
*
total
))
...
@@ -763,6 +793,8 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
...
@@ -763,6 +793,8 @@ class EncoderAlgorithm(QgsProcessingAlgorithm):
parameters
,
self
.
CUDA_ID
,
context
)
parameters
,
self
.
CUDA_ID
,
context
)
self
.
pauses
=
self
.
parameterAsInt
(
self
.
pauses
=
self
.
parameterAsInt
(
parameters
,
self
.
PAUSES
,
context
)
parameters
,
self
.
PAUSES
,
context
)
self
.
cleanup_frq
=
self
.
parameterAsInt
(
parameters
,
self
.
TEMP_FILES_CLEANUP_FREQ
,
context
)
self
.
nworkers
=
self
.
parameterAsInt
(
self
.
nworkers
=
self
.
parameterAsInt
(
parameters
,
self
.
WORKERS
,
context
)
parameters
,
self
.
WORKERS
,
context
)
merge_method_idx
=
self
.
parameterAsEnum
(
merge_method_idx
=
self
.
parameterAsEnum
(
...
...
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