Skip to content

[ENG-9828] - Backfill CedarMetadataRecord from CollectionSubmission custom metadata#11740

Open
Vlad0n20 wants to merge 5 commits into
CenterForOpenScience:feature/es2-consolidationfrom
Vlad0n20:feature/ENG-9828
Open

[ENG-9828] - Backfill CedarMetadataRecord from CollectionSubmission custom metadata#11740
Vlad0n20 wants to merge 5 commits into
CenterForOpenScience:feature/es2-consolidationfrom
Vlad0n20:feature/ENG-9828

Conversation

@Vlad0n20

@Vlad0n20 Vlad0n20 commented May 15, 2026

Copy link
Copy Markdown
Contributor

Ticket

Purpose

Changes

Side Effects

QE Notes

CE Notes

Documentation

@aaxelb aaxelb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command seems fine; mainly git book-keeping (requests for sync_cedar_metadata on #11735 )

Comment thread osf/models/collection_submission.py Outdated
logger.exception(e)
sentry.log_exception(e)

def sync_cedar_metadata(self):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this overlaps #11735 , why not put them in the same PR, or make this one based on that one, or move the sync_cedar_metadata definition into a separate commit shared by both PRs... any way to avoid defining the same function twice and having to go back and forth to check they're identical until the inevitable merge conflict...

@Vlad0n20 Vlad0n20 force-pushed the feature/ENG-9828 branch from 7e7f928 to dc1bbae Compare June 9, 2026 14:13

@aaxelb aaxelb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like sync_cedar_metadata was removed from both #11735 and this PR, so now doesn't exist

logger.info(f'[DRY RUN] Would sync cedar metadata for submission {submission._id}')
continue
try:
submission.sync_cedar_metadata()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well now i'm confused -- sync_cedar_metadata doesn't seem to exist?

nonlocal call_count
call_count += 1
if call_count == 1:
raise Exception('simulated error')

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: might be easier/cleaner to give side_effect a list to raise on the first call and succeed (return None) on the second:
mock.side_effect = [Exception('simulated error'), None]
https://docs.python.org/3.13/library/unittest.mock.html#unittest.mock.Mock.side_effect

with mock.patch.object(CollectionSubmission, 'sync_cedar_metadata', sync_side_effect):
copy_collection_submission_metadata_to_cedar()

assert call_count == 2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the mock already has this, no need to do it by hand -- _mock_sync_side_effect.call_count

copy_collection_submission_metadata_to_cedar()

record = CedarMetadataRecord.objects.get(guid=submission.guid, template=cedar_template)
assert record.metadata == {'status': 'new', '@context': cedar_template.cedar_id}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this @context is correct -- when you add sync_cedar_metadata, make sure its output is valid

@Vlad0n20 Vlad0n20 force-pushed the feature/ENG-9828 branch from 8aca88a to 29e9b04 Compare June 9, 2026 17:19
@adlius adlius requested a review from aaxelb June 9, 2026 18:45

@aaxelb aaxelb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

none of my previous comments were addressed -- this command is still broken (sync_cedar_metadata still doesn't exist) but now it's also untested

(the one fix for a non-deterministic test failure seems fine, tho unrelated)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants