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
6ab58b6c
Commit
6ab58b6c
authored
Jun 9, 2023
by
Bartosz Walkowiak
Browse files
Options
Downloads
Plain Diff
Merge branch 'new_report' into 'master'
New report See merge request
!3
parents
97c3cef8
93364b96
No related branches found
No related tags found
1 merge request
!3
New report
Pipeline
#12860
passed
Aug 23, 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
+19
-3
19 additions, 3 deletions
src/archive_extractor_worker.py
with
20 additions
and
4 deletions
.gitlab-ci.yml
+
1
−
1
View file @
6ab58b6c
...
...
@@ -25,7 +25,7 @@ build:
image
:
docker:18.09.7
only
:
-
master
-
develop
-
new_report
services
:
-
'
docker:18.09.7-dind'
script
:
...
...
This diff is collapsed.
Click to expand it.
src/archive_extractor_worker.py
+
19
−
3
View file @
6ab58b6c
...
...
@@ -6,6 +6,7 @@ import json
import
logging
import
os
import
shutil
import
time
from
enum
import
Enum
from
typing
import
Dict
,
List
,
Tuple
from
zipfile
import
ZipFile
,
is_zipfile
...
...
@@ -49,6 +50,7 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
INPUT_SIZES
=
'
input_sizes
'
OUTPUT_SIZES
=
'
output_sizes
'
CONVERTED
=
'
converted_files
'
CREATION_TIME
=
'
creation_time
'
ERROR_BEFORE
=
'
errors_before_conversion
'
ERROR_AFTER
=
'
errors_after_conversion
'
...
...
@@ -66,6 +68,17 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
cls
.
file_min_size
=
int
(
float
(
config
[
"
tool
"
].
get
(
"
file_min_size
"
,
cls
.
DEFAULT_FILE_MIN_SIZE
)))
@staticmethod
def
_get_creation_time
(
path_to_file
:
str
)
->
int
:
"""
Return file type.
:param path_to_file: path to file
:type path_to_file: str
:return: file size in bytes
:rtype: int
"""
return
time
.
ctime
(
os
.
path
.
getctime
(
path_to_file
))
@staticmethod
def
_get_file_size
(
path_to_file
:
str
)
->
int
:
"""
Return file type.
...
...
@@ -236,7 +249,8 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
def
_safe_report
(
self
,
input_size_report
:
Dict
,
input_size_sum
:
int
,
output_size_report
:
Dict
,
output_size_sum
:
int
,
error_report_before
:
Dict
,
error_report_after
:
Dict
,
files_to_convert
:
List
,
output_path
:
str
,
dir_path
:
str
):
files_to_convert
:
List
,
creation_time
:
int
,
output_path
:
str
,
dir_path
:
str
):
"""
Save size and error reports to json file.
:param input_size_report: input size report
...
...
@@ -262,6 +276,7 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
converted_files
=
[
self
.
_get_relpath
(
file_path
,
dir_path
)
for
file_path
in
files_to_convert
]
data
=
{
self
.
CREATION_TIME
:
creation_time
,
self
.
ERROR_BEFORE
:
error_report_before
,
self
.
CONVERTED
:
converted_files
,
self
.
ERROR_AFTER
:
error_report_after
,
...
...
@@ -312,6 +327,7 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
raise
Exception
(
"
Input is not a zip archive
"
)
dir_path
=
os
.
path
.
join
(
output_path
,
'
result
'
)
creation_time
=
self
.
_get_creation_time
(
input_path
)
os
.
mkdir
(
dir_path
)
self
.
_unpack_zip
(
input_path
,
dir_path
)
files_to_remove
,
files_to_convert
,
input_size_sum
=
[],
[],
0
...
...
@@ -370,5 +386,5 @@ class ArchiveExtractor(nlp_ws.NLPWorker):
self
.
_safe_report
(
input_size_report
,
input_size_sum
,
output_size_report
,
output_size_sum
,
error_report_before
,
error_report_after
,
files_to_convert
,
output_path
,
dir_path
)
error_report_after
,
files_to_convert
,
creation_time
,
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