agentscope.utils.common module
Common utils.
- class ImportErrorReporter(error: ImportError, extras_require: str | None = None)[source]
Bases:
object
Used as a placeholder for missing packages. When called, an ImportError will be raised, prompting the user to install the specified extras requirement.
- create_tempdir() Generator [source]
A context manager that creates a temporary directory and changes the current working directory to it. The implementation of this contextmanager are borrowed from https://github.com/openai/human-eval/blob/master/human_eval/execution.py
- timer(seconds: int | float | None = None) Generator [source]
A context manager that limits the execution time of a code block to a given number of seconds. The implementation of this contextmanager are borrowed from https://github.com/openai/human-eval/blob/master/human_eval/execution.py
Note
This function only works in Unix and MainThread, since signal.setitimer is only available in Unix.