-
Notifications
You must be signed in to change notification settings - Fork 1
ts streaming #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
ts streaming #13
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2a1c9cf
ts streaming
jwagenaar 6fa0aac
ts streaming
jwagenaar 0f8ddb1
Update src/pennsieve/timeSeries.py
jwagenaar 3d1500d
Update src/pennsieve/timeSeries.py
jwagenaar eff73e4
Update src/pennsieve/timeSeries.py
jwagenaar 12465f4
Update src/pennsieve/timeSeries.py
jwagenaar b8ce887
Update src/pennsieve/timeSeries.py
jwagenaar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,103 @@ | ||||
|
|
||||
| import numpy as np | ||||
| import pandas as pd | ||||
| from .protos import agent_pb2 | ||||
jwagenaar marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
| from .protos.agent_pb2 import GetTimeseriesChannelsResponse | ||||
| import pandas as pd | ||||
|
|
||||
| class TimeSeries: | ||||
| """ | ||||
| A class to represent operations on manifest. | ||||
|
|
||||
| Methods: | ||||
| -------- | ||||
| create(base_path): | ||||
| creates a new manifest with file(s) located in base_path | ||||
| add(manifest_id, base_path, targetBasePath='', recursive=True, files=None): | ||||
| adds a file(s) from base_path to a manifest with manifest_id | ||||
| in order to store them at targetBasePath on the server | ||||
| remove_file(manifest_id, file_id): | ||||
| removes a file with file_id from manifest with manifest_id | ||||
| delete(manifest_id): | ||||
| deletes a manifest with manifest_id | ||||
| list_manifests(): | ||||
| lists all available manifests | ||||
| get_manifest(manifest_id=None): | ||||
| gets the most recent manifest, or the manifest specified by manifest_id | ||||
| set_manifest(manifest_id=None): | ||||
| sets the manifest specified by manifest_id | ||||
| list_files(manifest_id, offset, limit): | ||||
| lists files for manifest with manifest_id, starting from the number defined by offset | ||||
| upload(manifest_id): | ||||
| initiates the upload of files definied in manifest with manifest_id | ||||
| start_upload(manifest_id): | ||||
| see: upload(manifest_id) | ||||
| cancel_upload(manifest_id, cancel_all=True): | ||||
| cancels the upload session for manifest_id or all upload sessions | ||||
| relocate_files(manifest_id, path, target_path): | ||||
| changes the target path of the manifest | ||||
| sync(manifest_id): | ||||
| synchronizes the state of the manifest between local and cloud server | ||||
| reset(manifest_id): | ||||
| allows users to reset the status for all files in a manifest | ||||
| """ | ||||
|
|
||||
| def __init__(self, stub): | ||||
| """Initialization of the timeseries class. | ||||
|
|
||||
| Parameters: | ||||
| ----------- | ||||
| stub : object | ||||
| Stub of an Agent | ||||
| """ | ||||
| self._stub = stub | ||||
|
|
||||
| def getChannels(self, dataset_id, package_id, refresh) -> GetTimeseriesChannelsResponse: | ||||
| request = agent_pb2.GetTimeseriesChannelsRequest( | ||||
| dataset_id=dataset_id, package_id=package_id, refresh=refresh | ||||
| ) | ||||
| response = self._stub.GetTimeseriesChannels(request=request) | ||||
| return response.channel | ||||
|
|
||||
| def getRangeForChannels( | ||||
| self, | ||||
| dataset_id, | ||||
| package_id, | ||||
| channel_ids, | ||||
| start_time, | ||||
| end_time, | ||||
| is_refresh, | ||||
| is_relative_time, | ||||
| ): | ||||
| request = agent_pb2.GetTimeseriesRangeRequest( | ||||
| dataset_id=dataset_id, | ||||
| package_id=package_id, | ||||
| channel_ids=channel_ids, | ||||
| start_time=start_time, | ||||
| end_time=end_time, | ||||
| refresh=is_refresh, | ||||
| relative_time=is_relative_time, | ||||
| ) | ||||
|
|
||||
| resultMap = {} | ||||
| for response in self._stub.GetTimeseriesRangeForChannels(request=request): | ||||
| if response.type == 2: | ||||
| continue | ||||
| if response.type == 1: | ||||
| values = list(response.data.data) | ||||
| index = np.linspace(response.data.start, response.data.end, len(values)) | ||||
| newVec = pd.Series(values, index=index, name=response.data.channel_id) | ||||
| if response.data.channel_id in resultMap: | ||||
| resultMap[response.data.channel_id] = pd.concat( | ||||
| [resultMap[response.data.channel_id], newVec] | ||||
| ) | ||||
| else: | ||||
| resultMap[response.data.channel_id] = newVec | ||||
|
|
||||
| result = pd.DataFrame() | ||||
| for key in resultMap: | ||||
| result[key] = resultMap[key] | ||||
|
|
||||
| return result | ||||
|
|
||||
|
|
||||
|
Comment on lines
+102
to
+103
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [formatters] reported by reviewdog 🐶
Suggested change
|
||||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[formatters] reported by reviewdog 🐶
pennsieve-agent-python/src/pennsieve/protos/agent_pb2.py
Lines 23 to 172 in 2a1c9cf