koji_habitude.resolver

koji_habitude.resolver

Resolver for units not defined in a Namespace.

For example a namespace may define a tag which inherits some parent, but that parent is not defined in the namespace. In order for a Solver to be able to perform depsolving, it must have some way to identify that parent tag. Therefore an Resolver creates a simple ReferenceObject placeholder for that parent tag.

author:

Christopher O’Brien <obriencj@gmail.com>

license:

GNU General Public License v3

ai-assistant:

Claude 3.5 Sonnet via Cursor

class koji_habitude.resolver.Reference(tp: Type[CoreObject], key: Tuple[str, str])

Bases: CoreModel, ResolvableMixin

A placeholder for a dependency that is not defined in the Namespace

can_split() → bool
change_report(resolver: Resolver) → ReferenceChangeReport
is_phantom() → bool
load_remote(session: MultiCallSession, reload: bool = False) → VirtualCall
model_config: ClassVar[ConfigDict] = {'validate_by_alias': True, 'validate_by_name': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_post_init(_IdentifiableMixin__context: Any)

Override this method to perform additional initialization after __init__ and model_construct. This is useful if you want to do some validation that requires the entire model to be initialized.

split() → Reference
property status: BaseStatus
tp: Type[CoreObject]
typename: ClassVar[str] = 'reference'
class koji_habitude.resolver.ReferenceChangeReport(obj: Resolvable, resolver: Resolver)

Bases: ChangeReport

A change report for a Reference object.

impl_compare()

Must be implemented by subclasses to perform the actual work of comparing the read Koji state with the expected state of the Base object, yielding Change instances as they are identified.

impl_read(session: MultiCallSession) → None
obj: Reference
class koji_habitude.resolver.Resolver(namespace: Namespace)

Bases: object

A Resolver finds dependency objects from a Namespace, or provides placeholder References for those that do not exist in that Namespace.

chain_resolve(key, into=None) → Dict[Tuple[str, str], CoreObject | Reference]

Resolve a key into either an object from the Namespace, or a Reference placeholder. If that object has dependencies, resolve them recursively as well.

Parameters:
  • key – The key to resolve

  • into – The dictionary to store the resolved objects

Returns:

A dictionary of all resolved objects by their keys

clear() → None

Clear the internal cache of missing objects. Any attempt to resolve a missing object will result in a new ReferenceObject placeholder being created.

load_remote_references(session: ClientSession, full=False) → None

creates a multicall for session, and queries for the existence of all current reference objects.

namespace_keys() → Iterable[Tuple[str, str]]

Iterator over the keys of the objects in the namespace.

phantom_keys() → List[Tuple[str, str]]

Iterator of reference keys that are currently phantom (ie. have not yet been found to exist in a Koji instance).

This is a convenience shortcut for reference_keys(exists=False)

reference_keys(exists: bool | None = None) → List[Tuple[str, str]]

Snapshot of the keys of objects not defined in the namespace, but which have been requested via the resolve method.

If exists is True, filter to only include objects which have been found (so far) to exist in a Koji instance.

If exists is False, filter to only include objects which have not been found to exist in the Koji instance.

Reference objects typically determine whether they exist or not via the invocation of their check_exists method, which is part of the Processor’s read and compare steps.

report() → ResolverReport

Creates a ResolverReport containing a snapshot of the current references

Returns:

the newly created report

resolve(key: Tuple[str, str]) → CoreObject | Reference

Resolve a key into either an object from the Namespace, or a ReferenceObject placeholder.

class koji_habitude.resolver.ResolverReport(discovered: Dict[Tuple[str, str], CoreObject | Reference], phantoms: Dict[Tuple[str, str], CoreObject | Reference])

Bases: object

A snapshot of the phantom and discovered objects in a Resolver, as returned by Resolver.report()

The phantom dict represents references that have not been found to exist in a Koji instance. The discovered dict represents references that have been found to exist in a Koji instance.

discovered: Dict[Tuple[str, str], CoreObject | Reference]
phantoms: Dict[Tuple[str, str], CoreObject | Reference]