Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
toargridding
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
toar-public
toargridding
Commits
4966c8c3
Commit
4966c8c3
authored
1 year ago
by
Simon Grasse
Browse files
Options
Downloads
Patches
Plain Diff
fix: incomplete query options, cache read
parent
067a83c8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!11
Creation of first beta release version
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
toargridding/toar_rest_client.py
+9
-7
9 additions, 7 deletions
toargridding/toar_rest_client.py
with
9 additions
and
7 deletions
toargridding/toar_rest_client.py
+
9
−
7
View file @
4966c8c3
...
...
@@ -22,10 +22,10 @@ class QueryOptions:
variable_id
:
str
statistics
:
str
sampling
:
str
min_data_capture
=
"
0
"
# TODO check effect on NaNs
metadata_scheme
=
"
basic
"
limit
=
"
None
"
format
=
"
by_statistic
"
min_data_capture
:
str
=
"
0
"
# TODO check effect on NaNs
metadata_scheme
:
str
=
"
basic
"
limit
:
str
=
"
None
"
format
:
str
=
"
by_statistic
"
@staticmethod
def
from_metadata
(
metadata
:
Metadata
):
...
...
@@ -45,11 +45,11 @@ class Cache:
def
__init__
(
self
,
cache_dir
):
self
.
cache_file
=
cache_dir
/
"
status_endpoints.json
"
if
not
self
.
cache_file
.
is_file
():
# initialize cache
if
not
self
.
cache_file
.
is_file
():
# initialize cache
with dummy values
with
open
(
self
.
cache_file
,
"
w
"
)
as
cache
:
json
.
dump
({
"
foo
"
:
"
bar
"
},
cache
)
def
__contains__
(
self
,
item
):
def
__contains__
(
self
,
item
:
str
):
with
self
.
storage_dict
()
as
storage
:
return
item
in
storage
.
keys
()
...
...
@@ -97,7 +97,7 @@ class Connection:
)
def
get_status_endpoint
(
self
,
query_options
:
QueryOptions
):
if
query_options
in
self
.
cache
:
if
query_options
.
cache_key
in
self
.
cache
:
status_endpoint
=
self
.
cache
.
get
(
query_options
.
cache_key
)
try
:
# test for stale cache
...
...
@@ -107,6 +107,8 @@ class Connection:
else
:
print
(
"
load status endpoint from cache
"
)
return
status_endpoint
else
:
print
(
"
query not in cache
"
)
status_endpoint
=
self
.
query_for_status_endpoint
(
query_options
)
return
status_endpoint
...
...
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