Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyFunc/DrawFunc dynamic reloading #341

Closed
bwsw opened this issue Aug 3, 2023 · 0 comments · Fixed by #359
Closed

PyFunc/DrawFunc dynamic reloading #341

bwsw opened this issue Aug 3, 2023 · 0 comments · Fixed by #359
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bwsw
Copy link
Contributor

bwsw commented Aug 3, 2023

A developer needs instruments to develop interactively. However, GStreamer/DeepStream takes time to initialize, which makes the development less productive. To overcome that, we must introduce a new feature allowing the pipeline to reload Python functions specified in YAML and the draw_function to be reloaded when the changes are detected.

The function is optional and configured with a global parameter defined in YAML: dynamic_reload: bool. If it is set to true the feature is enabled; otherwise, the code doesn't reload on change. By default, the flag must be set to false which is overridable with an environment variable DYNAMIC_RELOAD.

Dynamic reloading works on a per-message basis (that is why it is important to make it in a way to avoid extra checks when dynanic_reload is set to false). The framework, when forwards a message to a particular pyfunc checks if the corresponding module is changed. If there is a change, it reloads the module and recreates the Object according to the manifest (kwargs, yada-yada). The state is not copied from the old object. Finally, it replaces the old object instance with a new one and forwards the traffic.

It is important to implement an ultimate exception-handling solution covering all unhandled exceptions and pretty stack trace presentation (e.g., with https://pypi.org/project/pretty-traceback/).

When reloading happens, it must inform the user about it:

INFO Dynamic reloading is enabled and changes in `module.name.Cls` detected; reloading.
INFO The module `module.name.Cls` reloading complete: OK
OR
ERROR The module `module.name.Cls` reloading failed.
ERROR ------------------------ BEGIN ------------------------------------
ERROR stacktrace ... (pretty stacktrace)
ERROR ------------------------- END -------------------------------------

Keep in mind there could be multiple classes declared in a single module, so the reloading can be suboptimal from the module perspective (multiple reloads).

Please investigate if GST output messages also can be colored to conform the whole situation.

@bwsw bwsw added the enhancement New feature or request label Aug 3, 2023
@bwsw bwsw added this to the 0.2.5 milestone Aug 3, 2023
@bwsw bwsw moved this to Todo in Savant: 0.2.5 Aug 3, 2023
@abramov-oleg abramov-oleg self-assigned this Aug 7, 2023
@bwsw bwsw moved this from Todo to In Progress in Savant: 0.2.5 Aug 7, 2023
@abramov-oleg abramov-oleg linked a pull request Aug 16, 2023 that will close this issue
@abramov-oleg abramov-oleg moved this from In Progress to Review in Savant: 0.2.5 Aug 24, 2023
@bwsw bwsw closed this as completed in #359 Aug 29, 2023
@github-project-automation github-project-automation bot moved this from Review to Done in Savant: 0.2.5 Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants