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

Load private schemas in subfolder #1217

Open
udgover opened this issue Jan 9, 2025 · 1 comment
Open

Load private schemas in subfolder #1217

udgover opened this issue Jan 9, 2025 · 1 comment
Labels
core enhancement feature-request python Pull requests that update Python code

Comments

@udgover
Copy link
Collaborator

udgover commented Jan 9, 2025

It turns out that for private schemas they have to be at the root of the private folder to be able to be read. If private schemas are located under a subfolder such as private/foobar, they won't be loaded.

@udgover udgover added enhancement feature-request python Pull requests that update Python code core labels Jan 9, 2025
@1nv8rzim
Copy link
Contributor

1nv8rzim commented Jan 9, 2025

The other half of this, is that this is not logged properly.

The existing code never has module_name unless the file is found under core.schemas.{schema_root_type} or core.schemas.{schema_root_type}.private:

 for schema_file in Path(__file__).parent.glob(f"{schema_root_type}/**/*.py"):
        if schema_file.stem == "__init__":
            continue
        if schema_file.parent.stem == schema_root_type:
            # module_name set here
            module_name = f"core.schemas.{schema_root_type}.{schema_file.stem}"
        elif schema_file.parent.stem == "private":
            # and here
            module_name = f"core.schemas.{schema_root_type}.private.{schema_file.stem}"
        # any other case module_name is never set
        try:
            # and used here
            register_module(module_name, base_module)
        except Exception:
            logger.exception(f"Failed to register classes from {module_name}")

As I understand there should be logger.exception(f"Failed to register classes from {module_name}" which log module_name and None since it is never declared in the case that a nested schema exists. Nevertheless, when I found this issue, I could not find any logs to support this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core enhancement feature-request python Pull requests that update Python code
Projects
None yet
Development

No branches or pull requests

2 participants