Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
ldv_utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LDV
ldv_utils
Commits
5fab9d69
Commit
5fab9d69
authored
2 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
Add option to select datatype during query
parent
e5805d0a
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!7
Add option to select datatype during query
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
atdb_csv_gen/atdb_csv_gen/csv_gen.py
+29
-12
29 additions, 12 deletions
atdb_csv_gen/atdb_csv_gen/csv_gen.py
with
29 additions
and
12 deletions
atdb_csv_gen/atdb_csv_gen/csv_gen.py
+
29
−
12
View file @
5fab9d69
...
@@ -13,6 +13,10 @@ from sqlalchemy.engine.base import Connection, Engine
...
@@ -13,6 +13,10 @@ from sqlalchemy.engine.base import Connection, Engine
from
sqlalchemy.sql
import
text
from
sqlalchemy.sql
import
text
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
_EXPECTED_STR_PER_DATATYPE
=
{
'
MS
'
:
'
.MS_
'
,
'
BF
'
:
'
_bf.
'
}
def
parse_args
()
->
Namespace
:
def
parse_args
()
->
Namespace
:
...
@@ -32,6 +36,7 @@ def parse_args() -> Namespace:
...
@@ -32,6 +36,7 @@ def parse_args() -> Namespace:
parser
.
add_argument
(
parser
.
add_argument
(
"
--save-missing
"
,
type
=
str
,
help
=
"
Directory to store csv with missing files
"
"
--save-missing
"
,
type
=
str
,
help
=
"
Directory to store csv with missing files
"
)
)
parser
.
add_argument
(
"
--datatype
"
,
help
=
"
Select a specific datatype
"
,
choices
=
_EXPECTED_STR_PER_DATATYPE
.
keys
())
parser
.
add_argument
(
"
-v
"
,
action
=
"
store_true
"
,
help
=
"
Verbose logging
"
)
parser
.
add_argument
(
"
-v
"
,
action
=
"
store_true
"
,
help
=
"
Verbose logging
"
)
parser
.
add_argument
(
"
-q
"
,
action
=
"
store_true
"
,
help
=
"
Quiet logging (only errors)
"
)
parser
.
add_argument
(
"
-q
"
,
action
=
"
store_true
"
,
help
=
"
Quiet logging (only errors)
"
)
return
parser
.
parse_args
()
return
parser
.
parse_args
()
...
@@ -156,11 +161,20 @@ def match_file_lists(
...
@@ -156,11 +161,20 @@ def match_file_lists(
return
reg_data
.
intersection
(
cra_data
)
return
reg_data
.
intersection
(
cra_data
)
def
filter_datatype
(
size_path_list
,
datatype
):
if
datatype
is
None
:
return
size_path_list
else
:
expected_string
=
_EXPECTED_STR_PER_DATATYPE
[
datatype
]
return
[
item
for
item
in
size_path_list
if
expected_string
in
item
]
def
gen_csv
(
def
gen_csv
(
obs_id
:
str
,
obs_id
:
str
,
o_file
:
Optional
[
str
]
=
None
,
o_file
:
Optional
[
str
]
=
None
,
save_missing
:
Optional
[
str
]
=
None
,
save_missing
:
Optional
[
str
]
=
None
,
config_file
:
Optional
[
str
]
=
None
,
config_file
:
Optional
[
str
]
=
None
,
datatype
:
Optional
[
str
]
=
None
,
):
):
"""
Generate CSV file for ATDB
"""
Generate CSV file for ATDB
...
@@ -180,7 +194,9 @@ def gen_csv(
...
@@ -180,7 +194,9 @@ def gen_csv(
intersection
=
match_file_lists
(
registered
,
crawled
,
save_missing
)
intersection
=
match_file_lists
(
registered
,
crawled
,
save_missing
)
write_output
(
"
\n
"
.
join
(
intersection
),
o_file
)
filtered_intersection
=
filter_datatype
(
intersection
,
datatype
)
write_output
(
"
\n
"
.
join
(
filtered_intersection
),
o_file
)
def
main
():
def
main
():
...
@@ -198,6 +214,7 @@ def main():
...
@@ -198,6 +214,7 @@ def main():
o_file
=
args
.
o
,
o_file
=
args
.
o
,
save_missing
=
args
.
save_missing
,
save_missing
=
args
.
save_missing
,
config_file
=
args
.
c
,
config_file
=
args
.
c
,
datatype
=
args
.
datatype
)
)
...
...
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