Skip to content

Commit

Permalink
Merge branch 'put-object-options' into verify-put-object-options
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Dec 27, 2024
2 parents a7768a7 + ec0ae9c commit 2d94bdb
Show file tree
Hide file tree
Showing 19 changed files with 234 additions and 243 deletions.
4 changes: 2 additions & 2 deletions api/python/quilt3/data_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def add_put_options_safely(params: dict, put_options: Optional[dict]):
if put_options:
for key, value in put_options.items():
if key in params:
raise ValueError(f"Key {key} already exists in params.")
raise ValueError(f"Cannot override key `{key}` using put_options: {put_options}.")
params[key] = value
print(f"add_put_options_safely.PARAMS: {params}")

Expand Down Expand Up @@ -897,7 +897,7 @@ def copy_file_list(file_list, message=None, callback=None, put_options=None):
if _looks_like_dir(src) or _looks_like_dir(dest):
raise ValueError("Directories are not allowed")

return _copy_file_list_internal(file_list, [None] * len(file_list), message, callback, put_options=None)
return _copy_file_list_internal(file_list, [None] * len(file_list), message, callback, put_options=put_options)


def copy_file(src: PhysicalKey, dest: PhysicalKey, size=None, message=None, callback=None, put_options=None):
Expand Down
12 changes: 7 additions & 5 deletions api/python/tests/test_data_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,20 @@ def test_add_put_options_safely(self):
# Test that the function adds the options
options_empty = {}
data_transfer.add_put_options_safely(options_empty, OPTIONS_TEMPLATE)
assert options_empty == OPTIONS_TEMPLATE
self.assertEqual(options_empty, OPTIONS_TEMPLATE)

# Test that the function works when passed None
options_unchanged = OPTIONS_TEMPLATE.copy()
data_transfer.add_put_options_safely(options_unchanged, None)
assert options_unchanged == OPTIONS_TEMPLATE
self.assertEqual(options_unchanged, OPTIONS_TEMPLATE)

# Test that the function raises error if modifying the original options
# Test that the function raises error if it would modify the original options
options_original = OPTIONS_TEMPLATE.copy()
options_modified = {'SSECustomerKey': '987654321'}
with pytest.raises(ValueError):
data_transfer.add_put_options_safely(options_original, OPTIONS_TEMPLATE)
with pytest.raises(ValueError,
match="Cannot override key `SSECustomerKey` using put_options:"
" {'SSECustomerKey': '987654321'}."):
data_transfer.add_put_options_safely(options_original, options_modified)

def test_select(self):
# Note: The boto3 Stubber doesn't work properly with s3_client.select_object_content().
Expand Down
2 changes: 1 addition & 1 deletion catalog/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
'max-classes-per-file': 0,
'no-console': 2,
'no-nested-ternary': 1,
'no-restricted-globals': [2, "event", "location", "stop"],
'no-restricted-globals': [2, 'event', 'location', 'stop'],
'no-underscore-dangle': [2, { allow: ['_', '__', '__typename', '_tag'] }],
'prefer-arrow-callback': [2, { allowNamedFunctions: true }],
'prefer-template': 2,
Expand Down
1 change: 1 addition & 0 deletions catalog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!-- markdownlint-disable line-length -->

# Changelog

Changes are listed in reverse chronological order (newer entries at the top).
Expand Down
6 changes: 3 additions & 3 deletions catalog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ $ npm start
### Fetch

- An accurate check for a successful fetch() would include checking that
the promise resolved, then checking that the Response.ok property has
a value of true. The code would look something like this:
[msdn fetch doc](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)
the promise resolved, then checking that the Response.ok property has
a value of true. The code would look something like this:
[msdn fetch doc](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch)

## Deployment (for Quilt internal usage)

Expand Down
4 changes: 2 additions & 2 deletions catalog/app/containers/Admin/Status/Reports.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,14 +259,14 @@ export default function Reports({
invariant(queryResult.data?.status?.__typename !== 'Unavailable', 'Status unavailable')

const rows = (
pause ? firstPage : queryResult.data?.status?.reports.page ?? fallbacks.rows
pause ? firstPage : (queryResult.data?.status?.reports.page ?? fallbacks.rows)
) as StatusReport[]
if (rows !== fallbacks.rows) fallbacks.rows = rows

const isFiltered = !R.equals(defaults.filter, variables.filter)

const rowCount = isFiltered
? queryResult.data?.status?.reports.total ?? fallbacks.rowCount
? (queryResult.data?.status?.reports.total ?? fallbacks.rowCount)
: total
if (rowCount !== fallbacks.rowCount) fallbacks.rowCount = rowCount

Expand Down
12 changes: 6 additions & 6 deletions catalog/app/containers/Admin/UsersAndRoles/SsoConfig.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ function Data({ children, close }: DataProps) {
formApi: !deleting
? formApi
: deleting === true
? { ...formApi, submitting: true }
: {
...formApi,
submitError: deleting[FF.FORM_ERROR] || formApi.submitError,
submitFailed: true,
},
? { ...formApi, submitting: true }
: {
...formApi,
submitError: deleting[FF.FORM_ERROR] || formApi.submitError,
submitFailed: true,
},
close,
ssoConfig: data.admin?.ssoConfig,
})
Expand Down
4 changes: 2 additions & 2 deletions catalog/app/containers/Bucket/PackageCopyDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ function DialogForm({
workflow.slug === workflows.notAvailable
? null
: workflow.slug === workflows.notSelected
? ''
: workflow.slug,
? ''
: workflow.slug,
},
src: {
bucket,
Expand Down
16 changes: 8 additions & 8 deletions catalog/app/containers/Bucket/PackageDialog/FilesInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ const computeEntries = ({
state = !a.hash.ready
? ('hashing' as const)
: R.equals(a.hash.value, hash)
? ('unchanged' as const)
: ('modified' as const)
? ('unchanged' as const)
: ('modified' as const)
}
return { state, type, path, size: a.size, meta }
}
Expand All @@ -214,8 +214,8 @@ const computeEntries = ({
f === EMPTY_DIR_MARKER
? ('hidden' as const)
: S3FilePicker.isS3File(f)
? ('s3' as const)
: ('local' as const)
? ('s3' as const)
: ('local' as const)
return acc.concat({ state: 'added', type, path, size: f.size, meta: f.meta })
}, [] as IntermediateEntry[])
const entries: IntermediateEntry[] = [...existingEntries, ...addedEntries]
Expand Down Expand Up @@ -1618,10 +1618,10 @@ export function FilesInput({
disabled // eslint-disable-line no-nested-ternary
? 'disabled'
: error // eslint-disable-line no-nested-ternary
? 'error'
: warn.upload || warn.s3 || warn.count
? 'warn'
: undefined
? 'error'
: warn.upload || warn.s3 || warn.count
? 'warn'
: undefined
}
>
{title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,8 @@ function PackageCreationForm({
workflow.slug === workflows.notAvailable
? null
: workflow.slug === workflows.notSelected
? ''
: workflow.slug,
? ''
: workflow.slug,
},
src: {
entries: allEntries,
Expand Down
4 changes: 2 additions & 2 deletions catalog/app/containers/Bucket/PackageTree/PackageTree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ function DirDisplay({
const downloadLabel = !slt.isEmpty // eslint-disable-line no-nested-ternary
? 'Download selected'
: path
? 'Download sub-package'
: 'Download package'
? 'Download sub-package'
: 'Download package'
const downloadPath =
path && slt.isEmpty
? `package/${bucket}/${name}/${hash}/${path}`
Expand Down
4 changes: 2 additions & 2 deletions catalog/app/containers/Bucket/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export function LocalFolderInput({
disabledInternal // eslint-disable-line no-nested-ternary
? 'disabled'
: error // eslint-disable-line no-nested-ternary
? 'error'
: undefined
? 'error'
: undefined
}
>
{title}
Expand Down
26 changes: 10 additions & 16 deletions catalog/app/containers/Search/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export type PackagesFilterState = FilterState<typeof PackagesSearchFilterIO>
export type FilterStateForResultType<T extends ResultType> = T extends ResultType.S3Object
? ObjectsFilterState
: T extends ResultType.QuiltPackage
? PackagesFilterState
: never
? PackagesFilterState
: never

export type ObjectsSearchFilter = Model.GQLTypes.ObjectsSearchFilter
export type PackagesSearchFilter = Model.GQLTypes.PackagesSearchFilter
Expand Down Expand Up @@ -106,13 +106,8 @@ interface PredicateIO<Tag extends string, State, GQLType> {
export type PredicateState<PIO extends PredicateIO<any, any, any>> =
PIO extends PredicateIO<infer Tag, infer State, any> ? Tagged<Tag, State> : never

type PredicateGQLType<PIO extends PredicateIO<any, any, any>> = PIO extends PredicateIO<
any,
any,
infer G
>
? G
: never
type PredicateGQLType<PIO extends PredicateIO<any, any, any>> =
PIO extends PredicateIO<any, any, infer G> ? G : never

function Predicate<Tag extends string, State, GQLType>(input: {
tag: Tag
Expand Down Expand Up @@ -235,10 +230,10 @@ export type Extents =
export type ExtentsForPredicate<P> = P extends Predicates['Datetime']
? Model.GQLTypes.DatetimeExtents
: P extends Predicates['Number']
? Model.GQLTypes.NumberExtents
: P extends Predicates['KeywordEnum']
? Model.GQLTypes.KeywordExtents
: never
? Model.GQLTypes.NumberExtents
: P extends Predicates['KeywordEnum']
? Model.GQLTypes.KeywordExtents
: never

export type KnownPredicate = Predicates[keyof Predicates]

Expand Down Expand Up @@ -383,9 +378,8 @@ function Filter<PM extends PredicateMap>(children: PM): FilterIO<PM> {
}
}

type FilterState<FIO extends FilterIO<any>> = FIO extends FilterIO<infer PM>
? OrderedCombinedState<PM>
: never
type FilterState<FIO extends FilterIO<any>> =
FIO extends FilterIO<infer PM> ? OrderedCombinedState<PM> : never

export const ObjectsSearchFilterIO = Filter({
modified: Predicates.Datetime,
Expand Down
9 changes: 4 additions & 5 deletions catalog/app/utils/taggedV2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ interface Meta<TypeTag, VMap, CMap> {
export type InstanceOf<T> = T extends { meta: Meta<infer TypeTag, infer VMap, any> }
? Instance<TypeTag, keyof VMap, VMap[keyof VMap]>
: T extends InstanceConstructor<infer TypeTag, infer VariantTag, any, infer Value>
? Instance<TypeTag, VariantTag, Value>
: never
? Instance<TypeTag, VariantTag, Value>
: never

export type ConstructorOf<T> = T extends { meta: Meta<any, any, infer CMap> }
? CMap[keyof CMap]
: never

export type ValueOf<T> = T extends InstanceConstructor<any, any, any, infer Value>
? Value
: never
export type ValueOf<T> =
T extends InstanceConstructor<any, any, any, infer Value> ? Value : never

const mkCons =
<TypeTag>(typeTag: TypeTag) =>
Expand Down
5 changes: 1 addition & 4 deletions catalog/firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
"destination": "/index.html"
}
],
"ignore": [
"**/.*",
"robots.txt"
],
"ignore": ["**/.*", "robots.txt"],
"headers": [
{
"source": "**/*.@(jpg|jpeg|gif|png)",
Expand Down
Loading

0 comments on commit 2d94bdb

Please sign in to comment.