Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
datascout
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
ABP Computing
ABP Computing Sandbox
datascout
Commits
be8b62f3
Commit
be8b62f3
authored
3 years ago
by
Guido Sterbini
Browse files
Options
Downloads
Patches
Plain Diff
Update _datascout.py
parent
316f32e7
Branches
Branches containing commit
No related tags found
No related merge requests found
Checking pipeline status
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
datascout/_datascout.py
+46
-0
46 additions, 0 deletions
datascout/_datascout.py
with
46 additions
and
0 deletions
datascout/_datascout.py
+
46
−
0
View file @
be8b62f3
...
@@ -12,6 +12,7 @@ import datetime
...
@@ -12,6 +12,7 @@ import datetime
import
copy
import
copy
import
os
import
os
import
scipy
import
scipy
import
glob
from
pathlib
import
Path
from
pathlib
import
Path
...
@@ -509,3 +510,48 @@ def _compare_data(data1, data2, use_assert=False):
...
@@ -509,3 +510,48 @@ def _compare_data(data1, data2, use_assert=False):
_compare_data
(
data1
.
flatten
()[
i
],
data2
.
flatten
()[
i
],
use_assert
)
_compare_data
(
data1
.
flatten
()[
i
],
data2
.
flatten
()[
i
],
use_assert
)
else
:
else
:
not_equal
(
data1
,
data2
)
not_equal
(
data1
,
data2
)
def
_compare_schema
(
a
,
reference_file
=
None
,
verbose
=
False
):
"""
Compare the schema of a list of file **a**.
The default reference file in the first one of the list **a**.
It is possible to defien a different referenve file usint the **reference_file**.
"""
my_list
=
[]
if
len
(
a
)
>
0
:
if
verbose
:
print
(
f
'
Reference schema:
{
a
[
0
]
}
'
)
if
reference_file
==
None
:
reference_file
=
a
[
0
]
ref_schema
=
pq
.
read_schema
(
reference_file
)
for
ii
in
a
:
if
not
ref_schema
==
pq
.
read_schema
(
ii
):
if
verbose
:
print
(
f
'
\n
******
{
ii
}
has a different schema! ******
'
)
print
(
'
This is the difference
\n
=== Schema of the reference file ===
'
)
print
(
set
(
ref_schema
)
-
set
(
pq
.
read_schema
(
ii
)))
print
(
'
This is the difference
\n
=== Schema of the compared file ===
'
)
print
(
set
(
pq
.
read_schema
(
ii
))
-
set
(
ref_schema
))
my_list
.
append
(
ii
)
else
:
print
(
'
No file in the folder.
'
)
return
my_list
def
split_schemas
(
list_of_files
):
"""
Split a list of files by schemas.
"""
aux
=
_compare_schema
(
list_of_files
,
reference_file
=
None
,
verbose
=
False
)
if
len
(
aux
)
==
0
:
return
[
sorted
(
list_of_files
)]
else
:
return
[
sorted
(
list
(
set
(
list_of_files
)
-
set
(
aux
))),
*
split_schemas
(
aux
)]
def
compare_schema
(
folder
,
reference_file
=
None
,
verbose
=
False
):
"""
Given a **folder**, it compares all parquet files in it.
"""
return
_compare_schema
(
sorted
(
glob
.
glob
(
folder
+
'
/**/*.parquet
'
,
recursive
=
True
)),
reference_file
,
verbose
)
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