Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
archive_extractor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nlpworkers
archive_extractor
Commits
97c3cef8
Commit
97c3cef8
authored
Feb 28, 2023
by
Paweł Walkowiak
Browse files
Options
Downloads
Plain Diff
Merge branch 'develop' into 'master'
Develop See merge request
!2
parents
b75ca6de
50106399
No related branches found
No related tags found
1 merge request
!2
Develop
Pipeline
#10130
passed
May 8, 2023
Stage: check_style
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+1
-1
1 addition, 1 deletion
.gitlab-ci.yml
src/archive_extractor_worker.py
+28
-4
28 additions, 4 deletions
src/archive_extractor_worker.py
with
29 additions
and
5 deletions
.gitlab-ci.yml
+
1
−
1
View file @
97c3cef8
...
@@ -25,7 +25,7 @@ build:
...
@@ -25,7 +25,7 @@ build:
image
:
docker:18.09.7
image
:
docker:18.09.7
only
:
only
:
-
master
-
master
-
Init
-
develop
services
:
services
:
-
'
docker:18.09.7-dind'
-
'
docker:18.09.7-dind'
script
:
script
:
...
...
This diff is collapsed.
Click to expand it.
src/archive_extractor_worker.py
+
28
−
4
View file @
97c3cef8
...
@@ -236,7 +236,7 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
...
@@ -236,7 +236,7 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
def
_safe_report
(
self
,
input_size_report
:
Dict
,
input_size_sum
:
int
,
def
_safe_report
(
self
,
input_size_report
:
Dict
,
input_size_sum
:
int
,
output_size_report
:
Dict
,
output_size_sum
:
int
,
output_size_report
:
Dict
,
output_size_sum
:
int
,
error_report_before
:
Dict
,
error_report_after
:
Dict
,
error_report_before
:
Dict
,
error_report_after
:
Dict
,
files_to_convert
:
List
,
dir_path
:
str
):
files_to_convert
:
List
,
output_path
:
str
,
dir_path
:
str
):
"""
Save size and error reports to json file.
"""
Save size and error reports to json file.
:param input_size_report: input size report
:param input_size_report: input size report
...
@@ -253,6 +253,8 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
...
@@ -253,6 +253,8 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
:type error_report_after: Dict
:type error_report_after: Dict
:param files_to_convert: converted files
:param files_to_convert: converted files
:type files_to_convert: List
:type files_to_convert: List
:param output_path: Path to output location.
:type output_path: str
:param dir_path: Path to directory where the
:param dir_path: Path to directory where the
worker will store result files.
worker will store result files.
:type dir_path: str
:type dir_path: str
...
@@ -267,10 +269,28 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
...
@@ -267,10 +269,28 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
self
.
INPUT_SIZES_SUM
:
input_size_sum
,
self
.
INPUT_SIZES_SUM
:
input_size_sum
,
self
.
OUTPUT_SIZES
:
output_size_report
,
self
.
OUTPUT_SIZES
:
output_size_report
,
self
.
OUTPUT_SIZES_SUM
:
output_size_sum
}
self
.
OUTPUT_SIZES_SUM
:
output_size_sum
}
filename
=
os
.
path
.
join
(
dir
_path
,
'
report.json
'
)
filename
=
os
.
path
.
join
(
output
_path
,
'
report.json
'
)
with
open
(
filename
,
'
w
'
)
as
outfile
:
with
open
(
filename
,
'
w
'
)
as
outfile
:
json
.
dump
(
data
,
outfile
)
json
.
dump
(
data
,
outfile
)
def
_pack_result
(
self
,
output_path
:
str
,
dir_path
:
str
):
"""
Pack cleaned files to zip, removes unpacked files.
:param output_path: Path to output location.
:type output_path: str
:param dir_path: Path to directory where the
worker store result files.
:type dir_path: str
"""
zip_name
=
os
.
path
.
join
(
output_path
,
'
result.zip
'
)
_log
.
info
(
"
Packing results to zip...
"
)
with
ZipFile
(
zip_name
,
'
w
'
)
as
zip_obj
:
for
file_path
,
filename
in
self
.
_file_generator
(
dir_path
):
zip_obj
.
write
(
file_path
,
filename
)
_log
.
info
(
"
Packing completed, removing unpacked files
"
)
shutil
.
rmtree
(
dir_path
)
def
process
(
self
,
input_path
,
task_options
,
output_path
):
def
process
(
self
,
input_path
,
task_options
,
output_path
):
"""
Called for each request made to the worker.
"""
Called for each request made to the worker.
...
@@ -291,7 +311,8 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
...
@@ -291,7 +311,8 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
if
not
is_zipfile
(
input_path
):
if
not
is_zipfile
(
input_path
):
raise
Exception
(
"
Input is not a zip archive
"
)
raise
Exception
(
"
Input is not a zip archive
"
)
dir_path
=
output_path
dir_path
=
os
.
path
.
join
(
output_path
,
'
result
'
)
os
.
mkdir
(
dir_path
)
self
.
_unpack_zip
(
input_path
,
dir_path
)
self
.
_unpack_zip
(
input_path
,
dir_path
)
files_to_remove
,
files_to_convert
,
input_size_sum
=
[],
[],
0
files_to_remove
,
files_to_convert
,
input_size_sum
=
[],
[],
0
input_size_report
,
error_report_before
=
{},
{
member
.
value
:
[]
input_size_report
,
error_report_before
=
{},
{
member
.
value
:
[]
...
@@ -345,6 +366,9 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
...
@@ -345,6 +366,9 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
f
"
{
output_size_sum
}
is too large,
"
f
"
{
output_size_sum
}
is too large,
"
f
"
max size is
{
self
.
output_max_size
}
"
)
f
"
max size is
{
self
.
output_max_size
}
"
)
self
.
_pack_result
(
output_path
,
dir_path
)
self
.
_safe_report
(
input_size_report
,
input_size_sum
,
output_size_report
,
self
.
_safe_report
(
input_size_report
,
input_size_sum
,
output_size_report
,
output_size_sum
,
error_report_before
,
output_size_sum
,
error_report_before
,
error_report_after
,
files_to_convert
,
dir_path
)
error_report_after
,
files_to_convert
,
output_path
,
dir_path
)
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