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

Abr asair sensor #14445

Merged
merged 13 commits into from
Feb 28, 2024
Merged

Abr asair sensor #14445

merged 13 commits into from
Feb 28, 2024

Conversation

rclarke0
Copy link
Contributor

@rclarke0 rclarke0 commented Feb 7, 2024

Overview

This PR adds a script to the hardware-testing folder that will allow the robot to connect to an asair temperature and humidity sensor and record continuously to a google spread sheet.

Test Plan

I tested this script on robot DVT10 on software v7.1.1. It successfully measured the temperature and humidity and uploaded to the google sheet.

Changelog

Added abr-asair-sensor script
Script:

  1. Asks user for robot name
  2. Asks user for duration of recording (min)
  3. Asks user for frequency of recording (min)
  4. Robot reads ports and connects to asair sensor
  5. robot collects data and appends to a list at the given frequency
  6. At the end of the duration the robot saves a .csv file of the data to the testing-data folder within the robot and to the google sheet
    I also updated the analyze-abr script to improve ease of analysis.

IMPORTANT: MAKE SURE ANY BREAKING CHANGES ARE PROPERLY COMMUNICATED
-->

Review requests

Risk assessment

  • for the script to run successfully on the robot, google_sheets_tool.py and a google sheets credentials file needs to be uploaded manually onto the robot's jupyter notebook.
  • for google_sheets_tool.py to run successfully within the script python libraries: httplib2, oauth2client, gspread, and pprintpp need to be installed onto the robots

@rclarke0 rclarke0 requested a review from a team as a code owner February 7, 2024 21:35
@rclarke0 rclarke0 requested a review from andySigler February 7, 2024 21:54
Copy link

codecov bot commented Feb 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 68.14%. Comparing base (5fffd3e) to head (8e55ce9).
Report is 84 commits behind head on edge.

❗ Current head 8e55ce9 differs from pull request most recent head e0de99a. Consider uploading reports for the commit e0de99a to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #14445      +/-   ##
==========================================
- Coverage   68.15%   68.14%   -0.02%     
==========================================
  Files        1628     2518     +890     
  Lines       54954    72009   +17055     
  Branches     4141     9232    +5091     
==========================================
+ Hits        37452    49067   +11615     
- Misses      16814    20743    +3929     
- Partials      688     2199    +1511     
Flag Coverage Δ
hardware-testing ∅ <ø> (∅)

Flags with carried forward coverage won't be shown. Click here to find out more.

see 890 files with indirect coverage changes

)


def _get_user_input(list: List, some_string: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list is actually a predefined term in python - it is the name of the list type. defining a variable called list will shadow the global name in the scope where the variable is defined, which would lead to surprising results if you wanted to build a list in this function. Would you mind calling this something else, like lst or input_list or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to lst

)


def _get_user_input(list: List, some_string: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelatedly, List is a generic container type that is meant to be specialized with the type it contains - for instance, List[str] is a list of strings, List[int] is a list of ints.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added List[str]

return variable


class _abr_asair_sensor:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, common python style is for classes to be PascalCase - in this case, _ABRAsairSensor if the class isn't meant to be exported and ABRAsairSensor if it is

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed class name _ABRAsairSensor

@rclarke0 rclarke0 requested a review from a team as a code owner February 26, 2024 19:47
@rclarke0 rclarke0 requested a review from sfoster1 February 27, 2024 15:59
Copy link
Contributor

@andySigler andySigler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome. Just a few comments that shouldn't block merging

while True:
env_data = sensor.get_reading()
timestamp = datetime.datetime.now()
new_timestamp = timestamp - datetime.timedelta(hours=5)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this b/c of the timezone? either leaving a comment to describe what this is doing or somehow specifying the system's timezone would make it more clear

for sublist in results_list:
row_str = ", ".join(map(str, sublist)) + "\n" # type: str
result_string += row_str
save_file_path = data.append_data_to_file(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here you are appending the line to all previous lines, and then you appending that string to the file, and doing this for each line, which means that the file you are writing will be huge and filled with repeated lines.

This can be fixed by removing the result_string variable and just passing the row_str into append_data_to_file().

Then also, you can append each line to the CSV at the same time that you write the data to the google sheet. Just move the append_data_to_file() up into while loop above. Then the CSV will be updated in realtime, plus you don't need to store data in the results_list variable anymore.

@rclarke0 rclarke0 merged commit 2c5932f into edge Feb 28, 2024
6 checks passed
@rclarke0 rclarke0 deleted the abr-asair-sensor branch February 28, 2024 21:59
Carlos-fernandez pushed a commit that referenced this pull request May 20, 2024
<!--
Thanks for taking the time to open a pull request! Please make sure
you've read the "Opening Pull Requests" section of our Contributing
Guide:


https://github.com/Opentrons/opentrons/blob/edge/CONTRIBUTING.md#opening-pull-requests

To ensure your code is reviewed quickly and thoroughly, please fill out
the sections below to the best of your ability!
-->

# Overview

This PR adds a script to the hardware-testing folder that will allow the
robot to connect to an asair temperature and humidity sensor and record
continuously to a google spread sheet.


# Test Plan

I tested this script on robot DVT10 on software v7.1.1. It successfully
measured the temperature and humidity and uploaded to the google sheet.

# Changelog

Added abr-asair-sensor script
Script:

1. Asks user for robot name
2. Asks user for duration of recording (min)
3. Asks user for frequency of recording (min)
4. Robot reads ports and connects to asair sensor
5. robot collects data and appends to a list at the given frequency
6. At the end of the duration the robot saves a .csv file of the data to
the testing-data folder within the robot and to the google sheet
I also updated the analyze-abr script to improve ease of analysis.


IMPORTANT: MAKE SURE ANY BREAKING CHANGES ARE PROPERLY COMMUNICATED
-->

# Review requests

<!--
Describe any requests for your reviewers here.
-->

# Risk assessment

- for the script to run successfully on the robot, google_sheets_tool.py
and a google sheets credentials file needs to be uploaded manually onto
the robot's jupyter notebook.
- for google_sheets_tool.py to run successfully within the script python
libraries: httplib2, oauth2client, gspread, and pprintpp need to be
installed onto the robots
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants