Skip to content

ofrak_context.py

ofrak.ofrak_context

OFRAK

create_ofrak_context(self) async

Create the OFRAKContext and start all its services.

Source code in ofrak/ofrak_context.py
async def create_ofrak_context(self) -> OFRAKContext:
    """
    Create the OFRAKContext and start all its services.
    """
    self._setup()
    component_locator = await self.injector.get_instance(ComponentLocatorInterface)

    resource_factory = await self.injector.get_instance(ResourceFactory)
    component_locator.add_components(
        await self.injector.get_instance(List[ComponentInterface]), self._discovered_modules
    )

    id_service = await self.injector.get_instance(IDServiceInterface)
    data_service = await self.injector.get_instance(DataServiceInterface)
    resource_service = await self.injector.get_instance(ResourceServiceInterface)
    job_service = await self.injector.get_instance(JobServiceInterface)
    all_services = await self.injector.get_instance(List[AbstractOfrakService])

    ofrak_context = OFRAKContext(
        self.injector,
        resource_factory,
        component_locator,
        id_service,
        data_service,
        resource_service,
        job_service,
        all_services,
    )
    await ofrak_context.start_context()
    return ofrak_context

_setup(self) private

Discover common OFRAK services and components.

Source code in ofrak/ofrak_context.py
def _setup(self):
    """Discover common OFRAK services and components."""
    import ofrak

    self.discover(ofrak)
    try:
        import ofrak_components

        self.discover(ofrak_components)
    except ModuleNotFoundError:
        pass