Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inference
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
optima
inference
Commits
7030688d
Commit
7030688d
authored
4 years ago
by
Daalen, Tim van
Browse files
Options
Downloads
Patches
Plain Diff
wip, saving files for agenso
parent
fe9bad2f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Agenso_api.py
+15
-16
15 additions, 16 deletions
Agenso_api.py
data_types.py
+1
-1
1 addition, 1 deletion
data_types.py
global_vars.py
+1
-0
1 addition, 0 deletions
global_vars.py
inference.py
+2
-5
2 additions, 5 deletions
inference.py
with
19 additions
and
22 deletions
Agenso_api.py
+
15
−
16
View file @
7030688d
...
@@ -37,21 +37,21 @@ class AGENSO:
...
@@ -37,21 +37,21 @@ class AGENSO:
print
(
"
agenso login error: %s
"
%
str
(
e
))
print
(
"
agenso login error: %s
"
%
str
(
e
))
#send the json to AGENSO
#send the json to AGENSO
def
upload
(
self
,
token
,
json_data
):
def
upload
(
self
,
json_data
):
url
=
upload_url
url
=
upload_url
return
upload_helper
(
url
,
token
,
json_data
)
return
self
.
upload_helper
(
url
,
json_data
)
def
AGENSO_
bulkupload
(
token
,
json_data
):
def
bulkupload
(
self
,
json_data
):
url
=
bulk_upload_url
url
=
bulk_upload_url
return
upload_helper
(
url
,
token
,
json_data
)
return
self
.
upload_helper
(
url
,
json_data
)
#handles both normal and bluk uploads
#handles both normal and bluk uploads
#Returns a False if the upload failed
#Returns a False if the upload failed
#for normal upload: True if succesful
#for normal upload: True if succesful
#for bulk [[true,200],[true,200]] (for each subrequest)
#for bulk [[true,200],[true,200]] (for each subrequest)
def
upload_helper
(
self
,
url
,
token
,
json_data
):
def
upload_helper
(
self
,
url
,
json_data
):
status
=
False
status
=
False
params
=
{
'
api_token
'
:
token
}
params
=
{
'
api_token
'
:
self
.
token
}
headers
=
{
'
Content-Type
'
:
'
application/json
'
}
headers
=
{
'
Content-Type
'
:
'
application/json
'
}
try
:
try
:
r
=
requests
.
post
(
url
,
params
=
params
,
headers
=
headers
,
data
=
json_data
)
r
=
requests
.
post
(
url
,
params
=
params
,
headers
=
headers
,
data
=
json_data
)
...
@@ -68,9 +68,9 @@ class AGENSO:
...
@@ -68,9 +68,9 @@ class AGENSO:
#get data from AGENSO for a specific location/timestamp
#get data from AGENSO for a specific location/timestamp
#params = {"coordinates.latitude": 51.969189, "coordinates.longitude": 5.665395}
#params = {"coordinates.latitude": 51.969189, "coordinates.longitude": 5.665395}
#{"timestamp": 2020-07-02T11:53:50}
#{"timestamp": 2020-07-02T11:53:50}
def
retreive
(
token
,
params
):
def
retreive
(
self
,
params
):
result
=
""
result
=
""
params
[
'
api_token
'
]
=
token
params
[
'
api_token
'
]
=
self
.
token
r
=
requests
.
get
(
retreive_url
,
params
=
params
)
r
=
requests
.
get
(
retreive_url
,
params
=
params
)
if
(
r
.
status_code
!=
200
):
#Http Error
if
(
r
.
status_code
!=
200
):
#Http Error
print
(
"
URL: %s, statuscode: %d, reply: %s
"
%
(
retreive_url
,
r
.
status_code
,
r
.
text
))
print
(
"
URL: %s, statuscode: %d, reply: %s
"
%
(
retreive_url
,
r
.
status_code
,
r
.
text
))
...
@@ -81,11 +81,10 @@ class AGENSO:
...
@@ -81,11 +81,10 @@ class AGENSO:
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
#login
#login
token
=
AGENSO
_login
()
agenso
=
AGENSO
()
#upload data
#upload data
if
token
!=
None
:
test_data
=
{
test_data
=
{
"
timestamp
"
:
"
2020-07-02T11:53:50
"
,
"
timestamp
"
:
"
2020-07-02T11:53:50
"
,
"
gps_quality
"
:
"
fixed
"
,
"
gps_quality
"
:
"
fixed
"
,
"
hdop
"
:
1.4
,
"
hdop
"
:
1.4
,
...
@@ -105,7 +104,7 @@ if __name__ == '__main__':
...
@@ -105,7 +104,7 @@ if __name__ == '__main__':
}
}
]
]
}
}
data_json
=
json
.
dumps
(
test_data
,
sort_keys
=
True
,
indent
=
4
)
data_json
=
json
.
dumps
(
test_data
,
sort_keys
=
True
,
indent
=
4
)
status
=
AGENSO_
upload
(
token
,
data_json
)
status
=
agenso
.
upload
(
data_json
)
print
(
status
)
print
(
status
)
AGENSO_
retreive
(
token
,
{
"
coordinates.latitude
"
:
51.969189
,
"
coordinates.longitude
"
:
5.665395
})
agenso
.
retreive
(
{
"
coordinates.latitude
"
:
51.969189
,
"
coordinates.longitude
"
:
5.665395
})
This diff is collapsed.
Click to expand it.
data_types.py
+
1
−
1
View file @
7030688d
...
@@ -142,7 +142,7 @@ class GPS_Ringbuffer:
...
@@ -142,7 +142,7 @@ class GPS_Ringbuffer:
#return current GPS location as AGESO data class
#return current GPS location as AGESO data class
def
get_dataobject
(
self
,
timestamp
):
def
get_dataobject
(
self
,
timestamp
):
data_obj
=
data_class
()
data_obj
=
data_class
()
data_obj
.
timestamp
=
timestamp
data_obj
.
timestamp
=
timestamp
.
strftime
(
"
%y-%m-%dT%H:%M:%S
"
)
data_obj
.
set_gpsquality
(
self
.
data
[
self
.
point
].
gpsquality
)
data_obj
.
set_gpsquality
(
self
.
data
[
self
.
point
].
gpsquality
)
(
data_obj
.
lat
,
data_obj
.
lng
)
=
self
.
get_currentlocation
(
timestamp
)
(
data_obj
.
lat
,
data_obj
.
lng
)
=
self
.
get_currentlocation
(
timestamp
)
data_obj
.
hdop
=
self
.
data
[
self
.
point
].
hdop
data_obj
.
hdop
=
self
.
data
[
self
.
point
].
hdop
...
...
This diff is collapsed.
Click to expand it.
global_vars.py
+
1
−
0
View file @
7030688d
from
threading
import
Lock
from
threading
import
Lock
from
collections
import
deque
from
collections
import
deque
from
queue
import
Queue
from
queue
import
Queue
import
os
from
data_types
import
*
from
data_types
import
*
...
...
This diff is collapsed.
Click to expand it.
inference.py
+
2
−
5
View file @
7030688d
...
@@ -382,8 +382,8 @@ class dl_classification(Thread):
...
@@ -382,8 +382,8 @@ class dl_classification(Thread):
# Saves the values from the to_send_queue into files, they are later send to AGENSO in bluk
# Saves the values from the to_send_queue into files, they are later send to AGENSO in bluk
class
post_processing
(
Thread
,
CONFIG
):
class
post_processing
(
Thread
):
def
__init__
(
self
):
def
__init__
(
self
,
CONFIG
):
self
.
_running
=
True
self
.
_running
=
True
# Initialize the thread
# Initialize the thread
Thread
.
__init__
(
self
)
Thread
.
__init__
(
self
)
...
@@ -458,9 +458,6 @@ if __name__ == '__main__':
...
@@ -458,9 +458,6 @@ if __name__ == '__main__':
dl_thread
.
start
()
dl_thread
.
start
()
proc_res_thread
.
start
()
proc_res_thread
.
start
()
# processing_thread.start()
# processing_thread.start()
# post_pros_thread.start()
# post_pros_thread.start()
...
...
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