Skip to content

Commit

Permalink
Merge branch 'edge' into chore-7.3.0-release-merge-back
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhuff committed May 28, 2024
2 parents 2afa859 + 5cc9e8c commit 4583fb8
Show file tree
Hide file tree
Showing 1,449 changed files with 955,982 additions and 13,329 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@ hardware-testing/**
app-testing/files
# app testing don't format the snapshots
app-testing/tests/__snapshots__
opentrons-ai-server/package
5 changes: 2 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ module.exports = {
importNames: [
'useAllRunsQuery',
'useRunQuery',
'useLastRunCommandKey',
'useAllCommandsQuery',
'useCurrentMaintenanceRun',
'useDeckConfigurationQuery',
'useAllCommandsAsPreSerializedList',
],
message:
'The HTTP hook is deprecated. Utilize the equivalent notification wrapper (useNotifyX) instead.',
'HTTP hook deprecated. Use the equivalent notification wrapper (useNotifyXYZ).',
},
],
},
Expand Down Expand Up @@ -102,7 +102,6 @@ module.exports = {
'@typescript-eslint/no-unnecessary-type-assertion': 'warn',
'@typescript-eslint/no-unnecessary-boolean-literal-compare': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/consistent-type-imports': 'warn',
'@typescript-eslint/consistent-indexed-object-style': 'warn',
'@typescript-eslint/no-confusing-void-expression': 'warn',
'@typescript-eslint/ban-types': 'warn',
Expand Down
52 changes: 52 additions & 0 deletions .github/workflows/ai-server-lint-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# This workflow runs lint on pull requests that touch anything in the opentrons-ai-server directory

name: 'ai-server lint'

on:
pull_request:
paths:
- 'opentrons-ai-server/**'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:
lint:
name: 'ai-server lint'
timeout-minutes: 5
runs-on: 'ubuntu-latest'
steps:
- name: Checkout opentrons repo
uses: 'actions/checkout@v4'

- name: Setup Python
uses: 'actions/setup-python@v5'
with:
python-version: '3.12'
cache: 'pipenv'
cache-dependency-path: opentrons-ai-server/Pipfile.lock
- name: Setup
id: install
working-directory: ./opentrons-ai-server
run: make setup
- name: black-check
if: always() && steps.install.outcome == 'success' || steps.install.outcome == 'skipped'
working-directory: ./opentrons-ai-server
run: make black-check
- name: ruff
if: always() && steps.install.outcome == 'success' || steps.install.outcome == 'skipped'
working-directory: ./opentrons-ai-server
run: make ruff-check
- name: mypy
if: always() && steps.install.outcome == 'success' || steps.install.outcome == 'skipped'
working-directory: ./opentrons-ai-server
run: make mypy
- name: unit tests
if: always() && steps.install.outcome == 'success' || steps.install.outcome == 'skipped'
working-directory: ./opentrons-ai-server
run: make unit-test
6 changes: 3 additions & 3 deletions .github/workflows/components-test-build-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ jobs:
npm config set cache ./.npm-cache
yarn config set cache-folder ./.yarn-cache
make setup-js
- name: 'build typescript'
run: make build-ts
- name: 'build library'
- name: 'build typescript types'
run: make -C components build-ts
- name: 'build js bundle'
run: |
make -C components lib
# replace package.json stub version number with version from tag
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/hardware-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ on:
paths:
- 'Makefile'
- 'hardware-testing/**'
- 'api/**'
- 'shared-data/**'
- 'hardware/**'
- '.github/workflows/hardware-testing.yaml'
- '.github/actions/python/**'
branches:
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/opentrons-ai-client-dev-continuos-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: 'OpentronsAI edge continuous deployment to dev'

on:
push:
branches:
- edge
paths:
- 'opentrons-ai-client/**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.run_id }}
cancel-in-progress: true

env:
CI: true

jobs:
js-unit-test:
runs-on: 'ubuntu-22.04'
permissions:
id-token: write
contents: read
name: 'OpentronsAI edge continuous deployment to dev'
timeout-minutes: 10
steps:
- uses: 'actions/checkout@v3'
- uses: 'actions/setup-node@v3'
with:
node-version: '18.19.0'
- name: 'install udev'
run: |
# WORKAROUND: Remove microsoft debian repo due to https://github.com/microsoft/linux-package-repositories/issues/130. Remove line below after it is resolved
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update && sudo apt-get install libudev-dev
- name: 'set complex environment variables'
id: 'set-vars'
uses: actions/github-script@v6
with:
script: |
const { buildComplexEnvVars } = require(`${process.env.GITHUB_WORKSPACE}/.github/workflows/utils.js`)
buildComplexEnvVars(core, context)
- name: 'cache yarn cache'
uses: actions/cache@v3
with:
path: |
${{ github.workspace }}/.npm-cache/_prebuild
${{ github.workspace }}/.yarn-cache
key: js-${{ secrets.GH_CACHE_VERSION }}-${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
- name: 'setup-js'
run: |
npm config set cache ${{ github.workspace }}/.npm-cache
yarn config set cache-folder ${{ github.workspace }}/.yarn-cache
make setup-js
- name: 'build'
run: |
make -C opentrons-ai-client build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.DEV_AI_ROLE_ARN }}
aws-region: ${{ secrets.DEV_AI_REGION }}
- name: 'deploy to dev'
run: |
make -C opentrons-ai-client dev-deploy
139 changes: 131 additions & 8 deletions abr-testing/abr_testing/automation/google_sheets_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys
from datetime import datetime
from oauth2client.service_account import ServiceAccountCredentials # type: ignore[import]
from typing import Dict, List, Any, Set, Tuple
from typing import Dict, List, Any, Set, Tuple, Optional

"""Google Sheets Tool.
Expand Down Expand Up @@ -48,20 +48,22 @@ def open_worksheet(self, tab_number: int) -> Any:
"""Open individual worksheet within a googlesheet."""
return self.spread_sheet.get_worksheet(tab_number)

def create_worksheet(self, tab_name: int) -> None:
def create_worksheet(self, title: str) -> Optional[str]:
"""Create a worksheet with tab name. Existing spreadsheet needed."""
try:
self.spread_sheet.add_worksheet(tab_name, rows="1000", cols="26")
new_sheet = self.spread_sheet.add_worksheet(title, rows="2500", cols="40")
return new_sheet.id
except gspread.exceptions.APIError:
print("Work Sheet already exists")
print("Sheet already exists.")
return new_sheet.id

def write_header(self, header: List) -> None:
"""Write Header to first row if not present."""
header_list = self.worksheet.row_values(1)
if header_list != header:
self.worksheet.insert_row(header, self.row_index)

def write_to_row(self, data: List) -> None:
def write_to_row(self, data: List, title: str = "Sheet1") -> None:
"""Write data into a row in a List[] format."""
try:
self.row_index += 1
Expand All @@ -87,21 +89,100 @@ def delete_row(self, row_index: int) -> None:
"""Delete Row from google sheet."""
self.worksheet.delete_rows(row_index)

def batch_delete_rows(self, row_indices: List[int]) -> None:
"""Batch delete rows in list of indices."""
delete_body = {
"requests": [
{
"deleteDimension": {
"range": {
"sheetId": 0,
"dimension": "ROWS",
"startIndex": index,
"endIndex": index + 1,
}
}
}
for index in row_indices
]
}
self.spread_sheet.batch_update(body=delete_body)

def batch_update_cells(
self,
data: List[List[Any]],
start_column: str,
start_row: int,
sheet_id: str,
) -> None:
"""Writes to multiple cells at once in a specific sheet."""

def column_letter_to_index(column_letter: str) -> int:
"""Convert a column letter (e.g., 'A') to a 1-based column index (e.g., 1)."""
index = 0
for char in column_letter.upper():
index = index * 26 + (ord(char) - ord("A") + 1)
return index

requests = []
user_entered_value: Dict[str, Any] = {}
start_column_index = column_letter_to_index(start_column) - 1

for col_offset, col_values in enumerate(data):
column_index = start_column_index + col_offset
# column_letter = index_to_column_letter(column_index)
for row_offset, value in enumerate(col_values):
row_index = start_row + row_offset
try:
float_value = float(value)
user_entered_value = {"numberValue": float_value}
except ValueError:
user_entered_value = {"stringValue": str(value)}
requests.append(
{
"updateCells": {
"range": {
"sheetId": sheet_id,
"startRowIndex": row_index - 1,
"endRowIndex": row_index,
"startColumnIndex": column_index,
"endColumnIndex": column_index + 1,
},
"rows": [
{"values": [{"userEnteredValue": user_entered_value}]}
],
"fields": "userEnteredValue",
}
}
)

body = {"requests": requests}
self.spread_sheet.batch_update(body=body)

def update_cell(
self, row: int, column: int, single_data: Any
self, sheet_title: str, row: int, column: int, single_data: Any
) -> Tuple[int, int, Any]:
"""Update ONE individual cell according to a row and column."""
self.worksheet.update_cell(row, column, single_data)
self.spread_sheet.worksheet(sheet_title).update_cell(row, column, single_data)
return row, column, single_data

def get_all_data(self) -> Dict[str, Any]:
def get_all_data(self) -> List[Dict[str, Any]]:
"""Get all the Data recorded from worksheet."""
return self.worksheet.get_all_records()

def get_column(self, column_number: int) -> Set[str]:
"""Get all values in column."""
return self.worksheet.col_values(column_number)

def get_cell(self, sheet_title: str, cell: str) -> Any:
"""Get cell value with location ex: 'A1'."""
return self.spread_sheet.worksheet(sheet_title).acell(cell).value

def get_single_col_range(self, sheet_name: str, range: str) -> List:
"""Get cell values from one column range."""
values_range = self.spread_sheet.worksheet(sheet_name).range(range)
return [cell.value for cell in values_range]

def get_index_row(self) -> int:
"""Check for the next available row to write too."""
row_index = len(self.get_column(1))
Expand Down Expand Up @@ -141,3 +222,45 @@ def get_row_index_with_value(self, some_string: str, col_num: int) -> Any:
print("Row not found.")
return None
return row_index

def create_line_chart(
self,
titles: List[str],
series: List[Dict[str, Any]],
domains: List[Dict[str, Any]],
axis: Dict[str, Any],
col_position: int = 0,
sheet_id: str = "0",
) -> None:
"""Create chart of data on google sheet."""
request_body = {
"requests": [
{
"addChart": {
"chart": {
"spec": {
"title": titles[0],
"basicChart": {
"chartType": "LINE",
"legendPosition": "RIGHT_LEGEND",
"axis": axis,
"domains": domains,
"series": series,
"headerCount": 1,
},
},
"position": {
"overlayPosition": {
"anchorCell": {
"sheetId": sheet_id,
"rowIndex": 15,
"columnIndex": col_position,
}
}
},
}
}
}
]
}
self.spread_sheet.batch_update(body=request_body)
2 changes: 1 addition & 1 deletion abr-testing/abr_testing/automation/jira_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def create_ticket(
}
try:
response = requests.post(
f"{self.url}/rest/api/3/issue/",
f"{self.url}/rest/api/3/issue",
headers=self.headers,
auth=self.auth,
json=data,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,10 @@ def upload_calibration_offsets(
parser.add_argument(
"email", metavar="EMAIL", type=str, nargs=1, help="opentrons gmail."
)
parser.add_argument(
"ip_or_all",
metavar="IP_OR_ALL",
type=str,
nargs=1,
help="Enter 'ALL' to read IPs.json or type full IP address of 1 robot.",
)
args = parser.parse_args()
storage_directory = args.storage_directory[0]
folder_name = args.folder_name[0]
google_sheet_name = args.google_sheet_name[0]
ip_or_all = args.ip_or_all[0]
email = args.email[0]
# Connect to google drive.
try:
Expand All @@ -191,6 +183,7 @@ def upload_calibration_offsets(
except FileNotFoundError:
print(f"Add .json file with robot IPs to: {storage_directory}.")
sys.exit()
ip_or_all = input("IP Address or ALL: ")

if ip_or_all == "ALL":
ip_address_list = ip_file["ip_address_list"]
Expand Down
Loading

0 comments on commit 4583fb8

Please sign in to comment.