Fetching streams and events within a time range #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds the long-desired feature of fetching
stream data
,events
andraw_events
by bounding them within specificstart
andend
points, if required.Currently,
AnalysisGroup
'sfetch_stream()
,fetch_events()
andfetch_raw_events()
download all the data associated with the input slug. This feature is fine with the slug corresponds to a specific device or a datablock.There is a lot of good functionality implemented into
cloud_api
- persistent connection, concurrent fetching of resources, HTTP/REST error handling, fetching of API resources by object etc.To use all of this functionality implemented into
AnalysisGroup
andIOTileCloudChannel
for other applications - specificallyarch_factory
's machine models, fetch methods inAnalysisGroup
need to take time range into account. This is to prevent DB loading on the cloud.Since
AnalysisGroup
and its methods are used in several reports - this change could be disruptive - so enabling this by retaining the default behavior of thefetch_*
methods.What's in this PR:
Updated
fetch_stream()
method to allowstart
andend
specification. They are set toNone
by default. The input to these arguments could be a validdatetime
-compatible string or adatetime
objectdate_utils.py
get_utc_ts
- that acceptsstart
,end
arguments and creates a valid, ISO-format UTC timestamp from the arguments. If timezone information is not present in the arguments, then UTC timezone is forcedUpdated implementation of
fetch_datapoints()
inIOTileCloudChannel
to account forstart
andend
todf
anddata
APITODO:
fetch_events
andfetch_raw_events
methods