Skip to content

feat: Context+Settings APIs#230

Open
tmathern wants to merge 81 commits intovNextfrom
mathern/context
Open

feat: Context+Settings APIs#230
tmathern wants to merge 81 commits intovNextfrom
mathern/context

Conversation

@tmathern
Copy link
Collaborator

@tmathern tmathern commented Mar 4, 2026

Changes in this pull request

Main changes are in src/c2pa/c2pa.py.

  • Add Context and Settings APIs (+bump of c2pa-rs)
  • Add tests to verify feature parity of context APIs with existing APIs
  • Update examples, add "no_thumbnails.py" example showing how to use settings to turn off thumbnails
  • Update usage docs, and add ManagedResource class docs (more docs are in docs: Document Context+Settings API, Intents, Working Stores #235)
  • Remove unused toml settings file (Python only uses JSON settings)
  • Fix typos and bugs caused by typos in src/c2pa/lib.py
  • Prune some tests that tested features covered by other tests
  • Removed bindings for unused APIs (the "old" embeddable ones, which where not bound in Python), added missing bindings for fragments

Checklist

  • This PR represents a single feature, fix, or change (new API: context with settings).
  • All applicable changes have been documented.
  • Any TO DO items (or similar) have been entered as GitHub issues and the link to that issue has been included in a comment.

@tmathern tmathern self-assigned this Mar 4, 2026
@tmathern tmathern changed the title (wip) (wip Context+Settings) Mar 4, 2026
@tmathern tmathern changed the title (wip Context+Settings) feat: Context+Settings APIs Mar 9, 2026
@tmathern tmathern requested review from gpeacock and ok-nick March 9, 2026 17:47
@tmathern tmathern requested a review from ale-adobe March 9, 2026 22:13
Tania Mathern and others added 14 commits March 9, 2026 15:58
* fix: Managed resources docs

* fix: Docs

* fix: Docs

* fix: Docs

* fix: Docs

* fix: Update docs

---------

Co-authored-by: Tania Mathern <tania.mathern@gmail.comn>
* fix: New API

* fix: Review feedback on c2pa-rs PR

* fix: Docs

* v0.77.1 of c2pa-rs is released

* Update c2pa version to v0.77.1

* fix: Merge conflict mistake

---------

Co-authored-by: Tania Mathern <tania.mathern@gmail.comn>
settings = Settings.from_dict({"builder": {"thumbnail": {"enabled": False}}})

# Merge additional configuration
settings.update({"verify": {"remote_manifest_fetch": True}})

Choose a reason for hiding this comment

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

Does this overwrite if the property already exists? May be helpful to include an example that shows that it does or doesn't.

Copy link
Collaborator Author

@tmathern tmathern Mar 12, 2026

Choose a reason for hiding this comment

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

Yes, and examples are included (tests) + it's in the docs too, but in another PR with all the docs (that one is code only/mostly).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here: #235

Comment on lines +1381 to +1387
@property
@abstractmethod
def is_valid(self) -> bool: ...

def __init__(self, file_like_stream):
"""Initialize a new Stream wrapper around a file-like object
(or an in-memory stream).
@property
@abstractmethod
def execution_context(self): ...

Choose a reason for hiding this comment

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

I don't know if this is standard for Python, but I typically like to see function descriptions (I suppose docstrings in this case) in the abstract base classes to describe what the abstract methods should do at a high-level, so that subclasses have some guidance on their implementations.

I see that we have some docstrings for these in the ManagedResource and Context classes -- could they be copied here?

Comment on lines +1489 to +1492
"""Fluent builder for Context.

Use Context.builder() to create an instance.
"""

Choose a reason for hiding this comment

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

A bit off-topic, but what are the motivations behind implementing this in the fluent design pattern? I don't have a strong opinion about it, but just wondering if there was a particular driver behind it.

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.

2 participants