Skip to content

Conversation

I-Need-Sleep-Asap
Copy link
Contributor

No description provided.

@I-Need-Sleep-Asap I-Need-Sleep-Asap self-assigned this Oct 9, 2025
@I-Need-Sleep-Asap
Copy link
Contributor Author

I-Need-Sleep-Asap commented Oct 9, 2025

Newly generated html with this code looks as
configuration.html

from scaler.config.mixins import ConfigType


def find_project_root(marker: str = "pyproject.toml") -> pathlib.Path:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my initial solution was to hardcode this logic but decided to opt for this to make it robust incase directory structure change in future

Copy link
Collaborator

@rafa-be rafa-be left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not forget to add the generated config file to the .gitignore.

try:
module = importlib.import_module(module_name)
for name, obj in inspect.getmembers(module, inspect.isclass):
if dataclasses.is_dataclass(obj) and obj.__module__ == module_name:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we checked the section classes based on being a sub-classes of a Config mixin, instead of relying on dataclasses.

Copy link
Contributor Author

@I-Need-Sleep-Asap I-Need-Sleep-Asap Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rafa-be : To make this work, we need to introduce a marker class (lets name it ConfigSection) & make all Config classes such as ClusterConfig, SchedulerConfig etc to inherit from it. By inheriting from ConfigSection, a class is clearly designated for inclusion in the generated TOML configuration. This "opt-in" approach ensures the script only targets the intended classes without relying on implementation details or location.

However, @sharpener6 is very strict about using inheritance & i dont think this warrants the strict requirements. Please lemme know your thoughts

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can think of other ways.
Using decorators

def config_section(cls):
    cls._is_config_section = True  # Add an attribute to the class
    return cls

@config_section  # Apply the decorator right above the class definition
@dataclasses.dataclass
class ClusterConfig:
......

another idea is to use class atribute:

@dataclasses.dataclass
class ClusterConfig:
    _is_config_section = True  # Manually add the marker attribute
    
    scheduler_address: ZMQConfig
    # ... rest of the class

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