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

Add sandbox configuration #32

Open
jenniferjiangkells opened this issue Jun 7, 2024 · 3 comments
Open

Add sandbox configuration #32

jenniferjiangkells opened this issue Jun 7, 2024 · 3 comments
Labels
Component: Logging Issue/PR that addresses logging functionality good first issue Good for newcomers hacktoberfest Issues suitable for hacktoberfest

Comments

@jenniferjiangkells
Copy link
Member

jenniferjiangkells commented Jun 7, 2024

Description

Implement configurable logging in the start_sandbox function of the sandbox decorator. Currently, the logging is hardcoded, which limits flexibility for users who may want to adjust log levels or output formats based on their specific needs.

Context

The start_sandbox function initialises the service and sends requests through the client. Having configurable logging for this function would allow users to:

  • Adjust log levels (e.g., DEBUG, INFO, WARNING) based on their debugging needs
  • Customise log formats to include or exclude certain information
  • Direct logs to different outputs (console, file, etc.)

This enhancement would improve the usability and flexibility of our sandbox environment, especially for users who are debugging or integrating our tool into their workflows.

Possible Implementation

  1. Add a logging_config parameter to the start_sandbox function.
  2. Use Python's logging.config module to apply the configuration.
  3. Provide sensible defaults for users who don't specify a logging configuration.
import logging.config

def start_sandbox(
    self,
    service_id: str = "1",
    save_data: bool = True,
    save_dir: str = "./output/",
    logging_config: Optional[Dict] = None,
) -> None:
    """
    Starts the sandbox: initialises service and sends a request through the client.

    Args:
        service_id (str): The ID of the service to start. Defaults to "1".
        save_data (bool): Whether to save request and response data. Defaults to True.
        save_dir (str): Directory to save data in. Defaults to "./output/".
        logging_config (Optional[Dict]): Configuration for logging. If None, uses default config.
    """
    if logging_config:
        logging.config.dictConfig(logging_config)
    else:
        # Set up default logging configuration
        logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

    logger = logging.getLogger(__name__)

    # ... rest of the function ...

Possible Alternatives

  • Use environment variables for logging configuration instead of function parameters.
  • Implement a global logging configuration for the entire package, which the start_sandbox function would use.
  • Create a separate configure_logging function that users can call before start_sandbox.
@jenniferjiangkells jenniferjiangkells added Issue: Feature Request ✨ New feature or improvement to existing feature good first issue Good for newcomers labels Jun 7, 2024
@github-project-automation github-project-automation bot moved this to Backlog in HealthChain Jun 7, 2024
@jenniferjiangkells jenniferjiangkells added Component: Logging Issue/PR that addresses logging functionality and removed Issue: Feature Request ✨ New feature or improvement to existing feature labels Sep 16, 2024
@jenniferjiangkells jenniferjiangkells changed the title Set logging from configs Add sandbox configuration Sep 30, 2024
@jenniferjiangkells jenniferjiangkells added the hacktoberfest Issues suitable for hacktoberfest label Sep 30, 2024
@RINO-GAELICO
Copy link
Contributor

Hi @jenniferjiangkells I would like to work on this feature, may I be assigned to this issue?

@jenniferjiangkells
Copy link
Member Author

@RINO-GAELICO Thanks for your interest in contributing! ⭐️ We're not going to formally assign issues from now on but please feel free to start working on this, just let us know so others are aware!

@RINO-GAELICO
Copy link
Contributor

Hi @jenniferjiangkells, I opened a PR #82 for this issue. I created an ad hoc function that users can call before start_sandbox.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Logging Issue/PR that addresses logging functionality good first issue Good for newcomers hacktoberfest Issues suitable for hacktoberfest
Projects
Status: Todo
Development

No branches or pull requests

2 participants