Skip to content

Commit

Permalink
Merge branch 'edge' into app_odd-choose-language-screen
Browse files Browse the repository at this point in the history
  • Loading branch information
brenthagen committed Oct 24, 2024
2 parents 2c71732 + 02236b3 commit 53f86a5
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 28 deletions.
6 changes: 5 additions & 1 deletion api/src/opentrons/util/logging_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

from opentrons.config import CONFIG, ARCHITECTURE, SystemArchitecture

from opentrons_hardware.sensors import SENSOR_LOG_NAME
if ARCHITECTURE is SystemArchitecture.BUILDROOT:
from opentrons_hardware.sensors import SENSOR_LOG_NAME
else:
# we don't use the sensor log on ot2 or host
SENSOR_LOG_NAME = "unused"


def _host_config(level_value: int) -> Dict[str, Any]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ export function useHistoricRunDetails(
hostOverride?: HostConfig | null
): RunData[] {
const { data: allHistoricRuns } = useNotifyAllRunsQuery({}, {}, hostOverride)

return allHistoricRuns == null
? []
: allHistoricRuns.data.toSorted(
(a, b) =>
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
)
: // TODO(sf): figure out why .toSorted() doesn't work in vitest
allHistoricRuns.data
.map(t => t)
.sort(
(a, b) =>
new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime()
)
}
3 changes: 1 addition & 2 deletions app/src/pages/ODD/RobotDashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ export function RobotDashboard(): JSX.Element {
)

const recentRunsOfUniqueProtocols = (allRunsQueryData?.data ?? [])
.toReversed() // newest runs first
.reduce<RunData[]>((acc, run) => {
.reduceRight<RunData[]>((acc, run) => {
if (
acc.some(collectedRun => collectedRun.protocolId === run.protocolId)
) {
Expand Down
35 changes: 23 additions & 12 deletions scripts/deploy/lib/copyObject.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const mime = require('mime')
const { CopyObjectCommand } = require('@aws-sdk/client-s3')

// TODO(mc, 2019-07-16): optimize cache values
const getCopyParams = obj => ({
Expand All @@ -12,7 +13,7 @@ const getCopyParams = obj => ({
/**
* Copy an object to an S3 bucket
*
* @param {S3} s3 - AWS.S3 instance
* @param {S3Client} s3 - AWS SDK v3 S3Client instance
* @param {S3Object} sourceObj - Object to copy
* @param {string} destBucket - Destination bucket
* @param {string} [destPath] - Destination bucket folder (root if unspecified)
Expand All @@ -21,10 +22,10 @@ const getCopyParams = obj => ({
*
* @typedef S3Object
* @property {string} Bucket - Object bucket
* @property {String} Prefix - Deploy folder in bucket
* @property {string} Prefix - Deploy folder in bucket
* @property {string} Key - Full key to object
*/
module.exports = function copyObject(
module.exports = async function copyObject(
s3,
sourceObj,
destBucket,
Expand All @@ -37,18 +38,28 @@ module.exports = function copyObject(
const copyParams = getCopyParams(sourceObj)

console.log(
`${dryrun ? 'DRYRUN: ' : ''}Copy
Source: ${copySource}
Dest: /${destBucket}/${destKey}
Params: ${JSON.stringify(copyParams)}\n`
`${
dryrun ? 'DRYRUN: ' : ''
}Copy\nSource: ${copySource}\nDest: /${destBucket}/${destKey}\nParams: ${JSON.stringify(
copyParams
)}\n`
)

if (dryrun) return Promise.resolve()

const copyObjectParams = Object.assign(
{ Bucket: destBucket, Key: destKey, CopySource: copySource },
copyParams
)
const copyObjectParams = {
Bucket: destBucket,
Key: destKey,
CopySource: copySource,
...copyParams,
}

return s3.copyObject(copyObjectParams).promise()
try {
const command = new CopyObjectCommand(copyObjectParams)
await s3.send(command)
console.log(`Successfully copied to /${destBucket}/${destKey}`)
} catch (err) {
console.error(`Error copying object: ${err.message}`)
throw err
}
}
27 changes: 19 additions & 8 deletions scripts/deploy/lib/removeObject.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use strict'

const { DeleteObjectCommand } = require('@aws-sdk/client-s3');

/**
* Remove an object from S3
*
* @param {AWS.S3} s3 - AWS.S3 instance
* @param {S3Client} s3 - S3Client instance
* @param {S3Object} obj - Object to remove
* @param {boolean} [dryrun] - Don't actually remove anything
* @returns {Promise} Promise that resolves when the removal is complete
Expand All @@ -13,13 +15,22 @@
* @property {String} Prefix - Deploy folder in bucket
* @property {string} Key - Full key to object
*/
module.exports = function removeObject(s3, obj, dryrun) {
module.exports = async function removeObject(s3, obj, dryrun) {
console.log(
`${dryrun ? 'DRYRUN: ' : ''}Remove
Source: /${obj.Bucket}/${obj.Key}\n`
)
`${dryrun ? 'DRYRUN: ' : ''}Remove\nSource: /${obj.Bucket}/${obj.Key}\n`
);

if (dryrun) return Promise.resolve();

if (dryrun) return Promise.resolve()
// Construct the deleteObject command with the bucket and key
const deleteParams = { Bucket: obj.Bucket, Key: obj.Key };

return s3.deleteObject({ Bucket: obj.Bucket, Key: obj.Key }).promise()
}
try {
// Use the send method with DeleteObjectCommand
const result = await s3.send(new DeleteObjectCommand(deleteParams));
return result;
} catch (error) {
console.error('Error removing object:', error);
throw error;
}
};

0 comments on commit 53f86a5

Please sign in to comment.