Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Mapping Provider
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
geant-swd
Next Generation Map
Mapping Provider
Commits
f6fd65fc
Commit
f6fd65fc
authored
1 month ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
typehinting fixes, there's apparnetly no stub for influxdb v1 - ignoring
parent
ff66f379
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mapping_provider/backends/brian.py
+11
-7
11 additions, 7 deletions
mapping_provider/backends/brian.py
mapping_provider/backends/cache.py
+2
-2
2 additions, 2 deletions
mapping_provider/backends/cache.py
pyproject.toml
+4
-0
4 additions, 0 deletions
pyproject.toml
with
17 additions
and
9 deletions
mapping_provider/backends/brian.py
+
11
−
7
View file @
f6fd65fc
import
os
import
contextlib
import
contextlib
from
influxdb
import
InfluxDBClient
from
influxdb
import
InfluxDBClient
from
threading
import
Event
from
threading
import
Event
import
time
import
time
from
typing
import
Generator
,
Any
import
logging
import
logging
...
@@ -59,7 +59,7 @@ CACHED_SCID_RATES_SCHEMA = {
...
@@ -59,7 +59,7 @@ CACHED_SCID_RATES_SCHEMA = {
}
}
@contextlib.contextmanager
@contextlib.contextmanager
def
influx_client
(
influx_params
:
config
.
InfluxConnectionParams
):
def
influx_client
(
influx_params
:
config
.
InfluxConnectionParams
)
->
Generator
[
InfluxDBClient
]
:
"""
"""
context manager for creating an influx db connection
context manager for creating an influx db connection
...
@@ -87,7 +87,9 @@ def influx_client(influx_params: config.InfluxConnectionParams):
...
@@ -87,7 +87,9 @@ def influx_client(influx_params: config.InfluxConnectionParams):
client
.
close
()
client
.
close
()
def
_load_scid_rates_rows
(
influx_params
:
config
.
InfluxConnectionParams
,
window
:
str
=
'
24h
'
):
def
_load_scid_rates_rows
(
influx_params
:
config
.
InfluxConnectionParams
,
window
:
str
=
'
24h
'
)
->
Generator
[
dict
[
str
,
str
|
float
|
None
],
None
,
None
]:
"""
"""
Return the count of all fields, grouped by
Return the count of all fields, grouped by
hostname & interface_name.
hostname & interface_name.
...
@@ -127,14 +129,16 @@ def _load_scid_rates_rows(influx_params: config.InfluxConnectionParams, window:
...
@@ -127,14 +129,16 @@ def _load_scid_rates_rows(influx_params: config.InfluxConnectionParams, window:
yield
rate
yield
rate
def
load_scid_rates
(
influx_params
:
config
.
InfluxConnectionParams
):
def
load_scid_rates
(
influx_params
:
config
.
InfluxConnectionParams
)
->
list
[
dict
[
str
,
Any
]]
:
rates
=
[]
rates
=
[]
for
r
in
_load_scid_rates_rows
(
influx_params
):
for
r
in
_load_scid_rates_rows
(
influx_params
):
def
_bitrate_or_none
(
field_name
:
str
)
->
float
|
None
:
def
_bitrate_or_none
(
field_name
:
str
)
->
float
|
None
:
if
field_name
in
r
:
_rate
=
r
.
get
(
field_name
,
None
)
return
r
[
field_name
]
*
8
assert
isinstance
(
_rate
,
float
|
None
)
# mypy noise
return
None
if
_rate
:
return
_rate
*
8
return
_rate
# could be 0 or None
values
=
{
values
=
{
'
latest
'
:
{
'
latest
'
:
{
...
...
This diff is collapsed.
Click to expand it.
mapping_provider/backends/cache.py
+
2
−
2
View file @
f6fd65fc
...
@@ -22,9 +22,9 @@ def init(cache_dir: str) -> None:
...
@@ -22,9 +22,9 @@ def init(cache_dir: str) -> None:
logger
.
debug
(
f
"
set cache directory:
{
_cache_dir
}
"
)
logger
.
debug
(
f
"
set cache directory:
{
_cache_dir
}
"
)
def
set
(
filename
:
str
,
data
:
dict
[
str
,
Any
]
)
->
None
:
def
set
(
filename
:
str
,
data
:
Any
)
->
None
:
"""
"""
data must be
a
JSON-serializable
dict
.
data must be JSON-serializable.
"""
"""
assert
_cache_dir
is
not
None
,
"
cache_dir hasn
'
t been initialized
"
assert
_cache_dir
is
not
None
,
"
cache_dir hasn
'
t been initialized
"
with
open
(
os
.
path
.
join
(
_cache_dir
,
filename
),
'
w
'
)
as
f
:
with
open
(
os
.
path
.
join
(
_cache_dir
,
filename
),
'
w
'
)
as
f
:
...
...
This diff is collapsed.
Click to expand it.
pyproject.toml
+
4
−
0
View file @
f6fd65fc
...
@@ -11,6 +11,10 @@ strict = true
...
@@ -11,6 +11,10 @@ strict = true
warn_unused_ignores
=
true
warn_unused_ignores
=
true
warn_return_any
=
true
warn_return_any
=
true
[[tool.mypy.overrides]]
module
=
[
"influxdb"
]
ignore_missing_imports
=
true
[tool.coverage.run]
[tool.coverage.run]
source
=
[
"mapping_provider"
]
source
=
[
"mapping_provider"
]
omit
=
[
omit
=
[
...
...
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