Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MetObsCommon
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
MetObs
MetObsCommon
Commits
884b5411
Commit
884b5411
authored
7 years ago
by
Alex Diebold
Browse files
Options
Downloads
Patches
Plain Diff
working on _sync() functionality with possible experiment directory
parent
a237a305
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
metobscommon/archive/db.py
+41
-1
41 additions, 1 deletion
metobscommon/archive/db.py
with
41 additions
and
1 deletion
metobscommon/archive/db.py
+
41
−
1
View file @
884b5411
...
@@ -553,6 +553,8 @@ def _sync(args):
...
@@ -553,6 +553,8 @@ def _sync(args):
insts
=
[
i
.
name
for
i
in
all_instruments
]
insts
=
[
i
.
name
for
i
in
all_instruments
]
all_sites
=
session
.
query
(
Site
).
all
()
all_sites
=
session
.
query
(
Site
).
all
()
sites
=
[
s
.
name
for
s
in
all_sites
]
sites
=
[
s
.
name
for
s
in
all_sites
]
all_experiments
=
session
.
query
(
Experiment
).
all
()
exps
=
[
e
.
name
for
e
in
all_experiments
]
#make a temp exp
#make a temp exp
curr_exp
=
Experiment
(
name
=
'
sad
'
)
curr_exp
=
Experiment
(
name
=
'
sad
'
)
...
@@ -568,7 +570,8 @@ def _sync(args):
...
@@ -568,7 +570,8 @@ def _sync(args):
if
basename
in
insts
:
if
basename
in
insts
:
curr_site
=
session
.
query
(
Site
).
filter
(
Site
.
name
==
dirname
).
all
()[
0
]
curr_site
=
session
.
query
(
Site
).
filter
(
Site
.
name
==
dirname
).
all
()[
0
]
#curr_exp = session.query(Experiment).filter(Experiment.name == 'sad').all()[0]
#curr_exp = session.query(Experiment).filter(Experiment.name == 'sad').all()[0]
curr_inst
=
session
.
query
(
Instrument
).
filter
(
Instrument
.
name
==
basename
).
all
()[
0
]
curr_inst
=
session
.
query
(
Instrument
).
filter
(
Instrument
.
name
==
basename
)
curr_inst
=
curr_inst
.
filter
(
Instrument
.
site
.
has
(
name
=
dirname
)).
all
()[
0
]
for
f
in
files
:
for
f
in
files
:
curr_path
=
'
{}/{}/{}
'
.
format
(
dirname
,
basename
,
f
)
curr_path
=
'
{}/{}/{}
'
.
format
(
dirname
,
basename
,
f
)
for
curr_filetype
in
curr_inst
.
filetype
:
for
curr_filetype
in
curr_inst
.
filetype
:
...
@@ -579,6 +582,43 @@ def _sync(args):
...
@@ -579,6 +582,43 @@ def _sync(args):
break
break
session
.
commit
()
session
.
commit
()
'''
for step in os.walk(
'
data
'
):
...
:
if
step
[
2
]:
...:
path
=
step
[
0
]
...:
#dirname = os.path.dirname(path).split('/')[len(os.path.dirname(path).split('/'))-1]
...:
#basename = os.path.basename(path)
...:
site_name
=
path
.
split
(
'
/
'
)[
2
]
...:
inst_name
=
os
.
path
.
basename
(
path
)
...:
if
len
(
path
.
split
(
'
/
'
))
==
4
:
...:
exp_name
=
path
.
split
(
'
/
'
)[
3
]
...:
else
:
...:
exp_name
=
'
n/a
'
...:
files
=
step
[
2
]
...:
#print('site = {} --- inst = {} --- exp = {} --- files = {}'.format(site_name, inst_name, exp_name, files))
...:
#print('\t\t{}'.format(step))
...:
site
=
session
.
query
(
Site
).
filter
(
Site
.
name
==
site_name
).
all
()
...:
inst
=
session
.
query
(
Instrument
).
filter
(
Instrument
.
name
==
inst_name
)
...:
inst
=
inst
.
filter
(
Instrument
.
site
.
has
(
name
=
site_name
)).
all
()
...:
exp
=
session
.
query
(
Experiment
).
filter
(
Experiment
.
name
==
exp_name
).
all
()
...:
if
site
and
inst
and
exp
:
...:
site
=
site
[
0
]
...:
inst
=
inst
[
0
]
...:
exp
=
exp
[
0
]
...:
print
(
'
{} - {} - {}
'
.
format
(
site
.
name
,
inst
.
name
,
exp
.
name
))
...:
#if dirname in sites:
...:
#print('0 - dirname = {} -- basename = {} -- files = {}'.format(dirname, basename, files))
...:
#if basename in insts:
...:
#print('1 - dirname = {} -- basename = {} -- files = {}'.format(dirname, basename, files))
...:
#for f in files:
...:
#curr_path = 'data/{}/{}/{}'.format(dirname, basename, f)
...:
#print(curr_path)
...:
#elif basename in exps:
...:
#print('2 - dirname = {} -- basename = {} -- files = {}'.format(dirname, basename, files))
...:
#sitename = os.path.dirname(path).split('/')[len(os.path.dirname(path).split('/'))-1]
...:
#print('site = {} -- files = {}'.format(sitename, files))
'''
'''
query DataBase --- can choose multiple columns to query
'''
query DataBase --- can choose multiple columns to query
optional arguments:
optional arguments:
...
...
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