Skip to content
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

Issue 18 #54

Merged
merged 25 commits into from
Mar 29, 2021
Merged
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3f5be09
add config.py and read_data_from_file.py
Mar 9, 2021
ed63666
finalize dump_data_to_file
Mar 10, 2021
4b0a640
update cli args
Mar 12, 2021
254f410
add capability to export raw data to file when additional parameters …
Mar 12, 2021
9cb24ee
successfully replicate behavior of SpecDetails, handle duplicate spec…
Mar 15, 2021
ec28776
significant refactors + add fill transitions functionality
Mar 16, 2021
d78e497
create v2 based on new ServerSpecDetails class and refactored PhoneVi…
Mar 17, 2021
06b8185
finish script refactor, create general structure for dumping based on…
Mar 18, 2021
6b909cf
move read_until_done to spec_details
Mar 19, 2021
ffa5d27
add FileSpecDetails, configure proper output from PhoneView map
Mar 19, 2021
c0eb143
Add simple unit test with a mocking example
shankari Mar 22, 2021
e8c9fe0
add in code review changes aside from read_until_done
Mar 22, 2021
5746c99
Merge pull request #10 from MobilityNet/add_simple_unit_test
Mar 22, 2021
80c8638
add documentation to parser for dump_data_to_file
Mar 22, 2021
9a7ff44
fix PhoneView to use time series keys from emission
Mar 23, 2021
1821b87
mostly working FileSpecDetails, constants added to PhoneView
Mar 24, 2021
bee4c2a
fully working FileSpecDetails
Mar 25, 2021
1252e2d
updated notebooks + incorporated changes on PR
Mar 26, 2021
24832dc
Restore full tree display
shankari Mar 26, 2021
e942ab8
remove outputs from Evaluations_power_boxplots
Mar 29, 2021
0cf5836
Merge branch 'issue18' of https://github.com/singhish/mobilitynet-ana…
Mar 29, 2021
46c67c8
revert _master notebooks
Mar 29, 2021
e2d72f8
remove .DS_Store
Mar 29, 2021
550ea7a
remove .DS_Store from subfolders
Mar 29, 2021
fb7007d
Add quotes around the `DATASTORE_LOC` as well
shankari Mar 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions bin/dump_data_to_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import requests
import time
import argparse
import sys
import arrow
import json


def retrieve_data_from_server(datastore_url, key, user, start_ts, end_ts):
post_body = {
"user": user,
"key_list": key,
"start_time": start_ts,
"end_time": end_ts
}

print(f"Retrieving data for: {post_body=}")
try:
response = requests.post(f"{datastore_url}/datastreams/find_entries/timestamp", json=post_body)
print(f"{response=}")
response.raise_for_status()
ret_list = response.json()["phone_data"]
except Exception as e:
print(f"Got {type(e).__name__}: {e}, retrying...")
time.sleep(10)
response = requests.post(f"{datastore_url}/datastreams/find_entries/timestamp", json=post_body)
print(f"{response=}")
response.raise_for_status()
ret_list = response.json()["phone_data"]

for e in ret_list:
e["data"]["write_ts"] = e["metadata"]["write_ts"]

print(f"Found {len(ret_list)} entries")


def parse_args():
parser = argparse.ArgumentParser()

parser.add_argument("--datastore-url", type=str, default="http://localhost:8080")
parser.add_argument("--spec-id", type=str)

# if one of these arguments is specified, the others in this group must also be specified
if any(arg in sys.argv for arg in ["--key", "--user", "--start-ts", "--end-ts"]):
parser.add_argument("--key", type=str, required=True)
parser.add_argument("--user", type=str, required=True)
parser.add_argument("--start-ts", type=float, required=True)
parser.add_argument("--end-ts", type=float, required=True)
shankari marked this conversation as resolved.
Show resolved Hide resolved

return parser.parse_args()


def main():
args = parse_args()

# TODO: add spec_details/phone_view logic


if __name__ == "__main__":
main()