Skip to content

Commit

Permalink
Merge branch 'edge' into EXEC-418-run-orchestrator-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
TamarZanzouri committed May 17, 2024
2 parents da94cdf + 47f863b commit 2f18907
Show file tree
Hide file tree
Showing 1,532 changed files with 44,599 additions and 28,024 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
30 changes: 29 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ module.exports = {
'no-case-declarations': 'warn',
'prefer-regex-literals': 'warn',
'react/prop-types': 'warn',

// Enforce notification hooks
'no-restricted-imports': [
'error',
{
paths: [
{
name: '@opentrons/react-api-client',
importNames: [
'useAllRunsQuery',
'useRunQuery',
'useAllCommandsQuery',
'useCurrentMaintenanceRun',
'useDeckConfigurationQuery',
'useAllCommandsAsPreSerializedList',
],
message:
'HTTP hook deprecated. Use the equivalent notification wrapper (useNotifyXYZ).',
},
],
},
],
},

globals: {},
Expand Down Expand Up @@ -80,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 Expand Up @@ -137,5 +158,12 @@ module.exports = {
'cypress/unsafe-to-chain-command': 'warn',
},
},
// Allow HTTP hooks in notification wrappers and tests
{
files: ['app/src/resources/**', '**/__tests__/**test**'],
rules: {
'no-restricted-imports': 'off',
},
},
],
}
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
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
61 changes: 48 additions & 13 deletions abr-testing/abr_testing/automation/google_drive_tool.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
"""Google Drive Tool."""
import os
from typing import Set, Any, Optional
import io
import json
import sys
from typing import Set, Any, Optional, List, Dict
import webbrowser
import mimetypes
from oauth2client.service_account import ServiceAccountCredentials # type: ignore[import]
import googleapiclient # type: ignore[import]
from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
from googleapiclient.http import MediaIoBaseDownload

"""Google Drive Tool.
Expand All @@ -19,13 +23,17 @@ class google_drive:

def __init__(self, credentials: Any, folder_name: str, email: str) -> None:
"""Connects to google drive via credentials file."""
self.scope = ["https://www.googleapis.com/auth/drive"]
self.credentials = ServiceAccountCredentials.from_json_keyfile_name(
credentials, self.scope
)
self.drive_service = build("drive", "v3", credentials=self.credentials)
self.parent_folder = folder_name
self.email = email
try:
self.scope = ["https://www.googleapis.com/auth/drive"]
self.credentials = ServiceAccountCredentials.from_json_keyfile_name(
credentials, self.scope
)
self.drive_service = build("drive", "v3", credentials=self.credentials)
self.parent_folder = folder_name
self.email = email
except json.decoder.JSONDecodeError:
print("Error! Get file: https://console.cloud.google.com/apis/credentials")
sys.exit()

def list_folder(self, delete: Any = False) -> Set[str]:
"""List folders and files in Google Drive."""
Expand Down Expand Up @@ -88,7 +96,7 @@ def upload_file(self, file_path: str) -> str:

def upload_missing_files(self, storage_directory: str) -> None:
"""Upload missing files to Google Drive."""
# Read Google Drive .json files.
# Read .json files.
google_drive_files = self.list_folder()
google_drive_files_json = [
file for file in google_drive_files if file.endswith(".json")
Expand All @@ -111,7 +119,7 @@ def upload_missing_files(self, storage_directory: str) -> None:
except googleapiclient.errors.HttpError:
continue

# Fetch the updated file list after all files are uploaded
# Fetch the updated file list after all are uploaded
files = google_drive.list_folder(self)

file_names = [file for file in files]
Expand All @@ -122,9 +130,7 @@ def upload_missing_files(self, storage_directory: str) -> None:
f"File '{this_name}' was successfully uploaded with ID: {uploaded_file['id']}"
)
else:
print(
f"File '{this_name}' was not found in the list of files after uploading."
)
print(f"File '{this_name}' was not found after uploading.")
print(f"{len(files)} item(s) in Google Drive")

def open_folder(self) -> Optional[str]:
Expand Down Expand Up @@ -154,3 +160,32 @@ def share_permissions(self, file_id: str) -> None:
self.drive_service.permissions().create(
fileId=file_id, body=new_permission, transferOwnership=False # type: ignore
).execute()

def download_files(
self, files_to_download: List[Dict[str, Any]], save_directory: str
) -> None:
"""Download files to a specified directory."""
for file in files_to_download:
id = file["id"]
file_name = file["name"]
file_path = os.path.join(save_directory, file_name)
request = self.drive_service.files().get_media(fileId=id) # type: ignore[attr-defined]
fh = io.FileIO(file_path, "wb")
downloader = MediaIoBaseDownload(fh, request)
done = False
while done is False:
status, done = downloader.next_chunk()
print(f"Downloading {file_name}... {int(status.progress() * 100)}%")

def search_folder(self, search_strings: List[str], folder_id: str) -> List[Any]:
"""Search folder for files containing string from list."""
files_found = []
for search_string in search_strings:
query = f"'{folder_id}' in parents and name contains '{search_string}'"
response = (
self.drive_service.files()
.list(q=query, fields="files(id,name)")
.execute()
)
files_found.extend(response.get("files", []))
return files_found

0 comments on commit 2f18907

Please sign in to comment.