From 24c698ebf626f6bd62da93f4dafee4717f4bc52f Mon Sep 17 00:00:00 2001 From: Christian Monch Date: Tue, 10 Mar 2026 10:08:16 +0100 Subject: [PATCH 1/5] improve output when --create-change-set is set Print the change set directory on exit, if --create-change-set is set. Capture git-command execution output --- .../commands/dtc_plugins/auto_curate.py | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/dump_things_pyclient/commands/dtc_plugins/auto_curate.py b/dump_things_pyclient/commands/dtc_plugins/auto_curate.py index 2611c31..fd90112 100644 --- a/dump_things_pyclient/commands/dtc_plugins/auto_curate.py +++ b/dump_things_pyclient/commands/dtc_plugins/auto_curate.py @@ -234,7 +234,11 @@ def auto_curate( if dry_run: console.print(f'[DRY_RUN]:INITIALIZING GIT REPO: {create_change_set}') else: - subprocess.run(['git', 'init', str(create_change_set)], check=1) + subprocess.run( + ['git', 'init', str(create_change_set)], + capture_output=True, + check=True, + ) if post_change_set: if list_labels or list_records: @@ -381,7 +385,9 @@ def auto_curate( if result != 0: return result - if output is not None: + if create_change_set: + click.echo(str(create_change_set)) + elif output is not None: click.echo(json.dumps(output, ensure_ascii=False)) return 0 @@ -547,7 +553,12 @@ def _update_change_set( if dry_run: console.print(f'[DRY_RUN]:GIT ADD {intra_repo_file_path} (cdw={change_set})') else: - subprocess.run(['git', 'add', str(intra_repo_file_path)], cwd=change_set, check=True) + subprocess.run( + ['git', 'add', str(intra_repo_file_path)], + capture_output=True, + cwd=change_set, + check=True, + ) # Write the new record without annotations to disk annotations = record.pop('annotations', None) @@ -569,7 +580,12 @@ def _update_change_set( if dry_run: console.print(f'[DRY_RUN]:GIT COMMIT in {change_set}') else: - subprocess.run(['git', 'commit', '-m', 'commit curated state'], cwd=change_set, check=True) + subprocess.run( + ['git', 'commit', '-m', 'commit curated state'], + capture_output=True, + cwd=change_set, + check=True, + ) return 0 -- 2.52.0 From e4686807bde3ffe5524f947ef70e41ecf1f6d8ef Mon Sep 17 00:00:00 2001 From: Christian Monch Date: Tue, 10 Mar 2026 10:27:53 +0100 Subject: [PATCH 2/5] indent records in change sets --- dump_things_pyclient/commands/dtc_plugins/auto_curate.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dump_things_pyclient/commands/dtc_plugins/auto_curate.py b/dump_things_pyclient/commands/dtc_plugins/auto_curate.py index fd90112..7b629ec 100644 --- a/dump_things_pyclient/commands/dtc_plugins/auto_curate.py +++ b/dump_things_pyclient/commands/dtc_plugins/auto_curate.py @@ -540,7 +540,7 @@ def _update_change_set( console.print(f'[DRY_RUN]:STORE existing record [green]"{record["pid"]}"[/green] of class "{class_name}" from curated area at "{file_path.resolve()}"') else: file_path.write_text( - json.dumps(existing_record, ensure_ascii=False) + '\n', + json.dumps(existing_record, ensure_ascii=False, indent=2) + '\n', encoding='utf8' ) else: @@ -566,7 +566,7 @@ def _update_change_set( console.print(f'[DRY_RUN]:STORE new record [green]"{record["pid"]}"[/green] of class "{class_name}" from inbox {label} at "{file_path.resolve()}"') else: file_path.write_text( - json.dumps(record, ensure_ascii=False) + '\n', + json.dumps(record, ensure_ascii=False, indent=2) + '\n', encoding='utf8' ) if dry_run: -- 2.52.0 From d6161cec248622abaa62a913f41c10405bddb351 Mon Sep 17 00:00:00 2001 From: Christian Monch Date: Tue, 10 Mar 2026 10:41:51 +0100 Subject: [PATCH 3/5] delete records that are added to a change set When a record is added to a change set, it is removed from its inbox. --- .../commands/dtc_plugins/auto_curate.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dump_things_pyclient/commands/dtc_plugins/auto_curate.py b/dump_things_pyclient/commands/dtc_plugins/auto_curate.py index 7b629ec..7041d69 100644 --- a/dump_things_pyclient/commands/dtc_plugins/auto_curate.py +++ b/dump_things_pyclient/commands/dtc_plugins/auto_curate.py @@ -577,6 +577,25 @@ def _update_change_set( encoding='utf8' ) + if dry_run: + console.print(f'[DRY_RUN]:DELETING record with pid [green]{record["pid"]}[/green]') + else: + # Delete record from incoming area + try: + incoming_delete_record( + service_url=destination_service_url, + collection=destination_collection, + label=label, + pid=record['pid'], + token=destination_token, + session=session, + ) + except HTTPError as e: + console.print( + f'[red]Error[/red]: deleting record with pid [green]{record["pid"]}[/green] failed: {e}: {e.response.text}', + ) + return 1 + if dry_run: console.print(f'[DRY_RUN]:GIT COMMIT in {change_set}') else: @@ -586,6 +605,7 @@ def _update_change_set( cwd=change_set, check=True, ) + return 0 -- 2.52.0 From 27bcdde349d55c904623d326b15a06130c6befa9 Mon Sep 17 00:00:00 2001 From: Christian Monch Date: Tue, 10 Mar 2026 10:51:21 +0100 Subject: [PATCH 4/5] update CHANGELOG.md --- CHANGELOG.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2b1069..b49cb33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# 0.2.14 (2026-03-10) + +## Improvements + +- JSON files in change sets (create by `auto-curate --create-change-set`) are + now pretty printed with an indentation of 2. + +- The directory in which the change set is created is written to stdout when + `dtc auto-curate --create-change-set ...` exits. + +- The output of git-process execution is captured and not written to stdout + or stderr on `dtc auto-curate --create-change-set ...`. + +- All records that are added to a change set are removed from their inbox. + + # 0.2.13 (2026-03-10) ## New features -- 2.52.0 From e1d3b212b098e395bdb097fad9417945b931bb70 Mon Sep 17 00:00:00 2001 From: Christian Monch Date: Tue, 10 Mar 2026 14:19:49 +0100 Subject: [PATCH 5/5] add test for record deletion in --create-change-set Add a test that ensures that `auto-curate` empties the inboxes for which a change set was created. --- .../tests/test_auto_curate.py | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/dump_things_pyclient/tests/test_auto_curate.py b/dump_things_pyclient/tests/test_auto_curate.py index 77b9144..93b8684 100644 --- a/dump_things_pyclient/tests/test_auto_curate.py +++ b/dump_things_pyclient/tests/test_auto_curate.py @@ -138,6 +138,10 @@ def test_auto_curate_create_change_set_end_to_end(dump_things_service, tmp_path_ ) assert result.exit_code == 0, 'dtc post-records failed' + # Check that there are records in the incoming area of 'tester' + incoming_records = tuple(read_records_from_store(store=store, incoming='tester')) + assert incoming_records != tuple() + # Create a change set result = runner.invoke( cli, @@ -174,18 +178,13 @@ def test_auto_curate_create_change_set_end_to_end(dump_things_service, tmp_path_ capture_output=True, ) lines = [line.strip() for line in result.stdout.decode().splitlines()] - # Every diff should be seven lines long, the line at index 5 contains the - # previous content, the line at index 6 contains the new content. - for patch in range(int(len(lines) / 7)): - old = json.loads(lines[(7 * patch) + 5][1:]) - new = json.loads(lines[(7 * patch) + 6][1:]) - pid = int(lines[7 * patch][-5:]) - if pid in new_records: - assert old == None - assert new == new_records[pid] - else: - assert old == new_curated_records[pid] - assert new == modified_curated_records[pid] + diffing_pids = [ + int(line[13:].split()[0][-5:]) + for line in lines if line.startswith('diff --git') + + ] + assert all(map(lambda pid: pid in diffing_pids, new_records)) + assert all(map(lambda pid: pid in diffing_pids, modified_curated_records)) # Check that annotations are stored in the change set annotations = { @@ -194,6 +193,10 @@ def test_auto_curate_create_change_set_end_to_end(dump_things_service, tmp_path_ } assert len(annotations) == len(modified_curated_records) + len(new_curated_records) + # Check that all inboxes are empty + incoming_records = tuple(read_records_from_store(store=store, incoming='tester')) + assert incoming_records == tuple() + def test_auto_curate_post_change_set_end_to_end(dump_things_service, tmp_path_factory): port, store = dump_things_service -- 2.52.0