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

Expose tuber.server.main() for user API #43

Merged
merged 1 commit into from
Sep 12, 2024

Conversation

arahlin
Copy link
Contributor

@arahlin arahlin commented Sep 12, 2024

This PR allows using the main() function in the __main__ block of user code. For example:

registry = {"my_object": MyObject()}

if __name__ == "__main__":
    from tuber.server import main

    main(registry=registry)

The registry script then automatically provides the tuberd command-line interface, with the registry pre-loaded by the user.

This PR also replaces the fragile exec call with an importlib interface for loading a registry from a file path.

This PR allows using the main() function in the `__main__` block of user code.
For example:

```
registry = {"my_object": MyObject()}

if __name__ == "__main__":
    from tuber.server import main

    main(registry=registry)
```

The registry script then automatically provides the `tuberd` command-line
interface, with the registry pre-loaded by the user.

This PR also replaces the fragile `exec` call with an importlib interface for
loading a registry from a file path.
@gsmecher gsmecher merged commit d4a54ea into gsmecher:master Sep 12, 2024
7 checks passed
@arahlin arahlin deleted the main_api branch September 12, 2024 23:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants