Skip to content

Commit

Permalink
Merge pull request #19 from simonsobs/init
Browse files Browse the repository at this point in the history
Remove hookspecs `initial_run_no()` and `initial_script()`
  • Loading branch information
TaiSakuma authored Dec 8, 2023
2 parents 76a2c1f + 5700708 commit 0a5911b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
10 changes: 0 additions & 10 deletions nextlinegraphql/hook/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ def configure(settings: Dynaconf, hook: pluggy.PluginManager) -> None:
'''Initialize the plugin.'''


@hookspec
def initial_run_no() -> Optional[int]:
'''Run No. of the first run.'''


@hookspec
def initial_script() -> Optional[str]:
'''The script of the first run.'''


@hookspec
def schema() -> Optional[tuple[type, type | None, type | None]]:
'''The GraphQL schema (Query, Mutation, Subscription)'''
Expand Down
10 changes: 3 additions & 7 deletions nextlinegraphql/plugins/ctrl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,14 @@ def schema(self):
return (Query, Mutation, Subscription)

@spec.hookimpl
async def update_lifespan_context(
self, hook: pluggy.PluginManager, context: MutableMapping
) -> None:
run_no: int = max(hook.hook.initial_run_no(), default=1)
script: str = [*hook.hook.initial_script(), statement][0]
self._nextline = Nextline(script, run_no)
async def update_lifespan_context(self, context: MutableMapping) -> None:
self._nextline = Nextline(statement)
self._stdout_cache = list[str]()
context['nextline'] = self._nextline

@spec.hookimpl(trylast=True) # trylast so to be the innermost context
@asynccontextmanager
async def lifespan(self) -> AsyncIterator[None]:
async def lifespan(self, hook: pluggy.PluginManager) -> AsyncIterator[None]:
'''Yield within the nextline context.'''
async with (self._nextline, self._cache_stdout()):
yield
Expand Down

0 comments on commit 0a5911b

Please sign in to comment.