use better defaults for dtc auto-curate options #23

Merged
cmo merged 1 commit from issue-20 into master 2026-02-03 21:37:11 +00:00

View file

@ -44,17 +44,17 @@ stl_info = False
@click.option( @click.option(
'--destination-service-url', '--destination-service-url',
metavar='DEST_SERVICE_URL', metavar='DEST_SERVICE_URL',
help='select a different dump-thing-service, i.e. not SERVICE_URL, as destination for auto-curated records', help='select a different dump-thing-service, i.e. not SERVICE_URL, as destination for auto-curated records (the default is SERVICE_URL)',
) )
@click.option( @click.option(
'--destination-collection', '--destination-collection',
metavar='DEST_COLLECTION', metavar='DEST_COLLECTION',
help='select a different collection, i.e. not the COLLECTION of SERVICE_URL, as destination for auto-curated records', help='select a different collection, i.e. not COLLECTION, as destination for auto-curated records',
) )
@click.option( @click.option(
'--destination-token', '--destination-token',
metavar='DEST_TOKEN', metavar='DEST_TOKEN',
help='if provided, this token will be used the authenticate again DEST_SERVICE_URL, otherwise the token for SERVICE_URL will be used', help='if provided, this token will be used the authenticate against DEST_SERVICE_URL, which defaults to SERVICE_URL (the default is the token provided via --token)',
) )
@click.option( @click.option(
'--pid', '-p', '--pid', '-p',
@ -154,6 +154,12 @@ def auto_curate(
console.print(f'[red]Error[/red]: no token was provided (use --token or DTC_TOKEN environment variable)') console.print(f'[red]Error[/red]: no token was provided (use --token or DTC_TOKEN environment variable)')
return 1 return 1
if destination_service_url is None:
destination_service_url = service_url
if destination_token is None:
destination_token = curator_token
output = None output = None
# If --list-labels and --list-records are provided, keep only the latter, # If --list-labels and --list-records are provided, keep only the latter,
@ -257,7 +263,8 @@ def auto_curate(
collection=destination_collection, collection=destination_collection,
class_name=class_name, class_name=class_name,
record=record, record=record,
token=destination_token) token=destination_token,
)
except HTTPError as e: except HTTPError as e:
console.print( console.print(
f'[red]Error[/red]: writing record with pid {record["pid"]} failed: {e}: {e.response.text}', f'[red]Error[/red]: writing record with pid {record["pid"]} failed: {e}: {e.response.text}',
@ -271,7 +278,7 @@ def auto_curate(
collection=collection, collection=collection,
label=label, label=label,
pid=record['pid'], pid=record['pid'],
token=obj, token=curator_token,
) )
except HTTPError as e: except HTTPError as e:
console.print( console.print(