Skip to content
New issue

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

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

Already on GitHub? # to your account

Not able to run without profiling master branch #322

Closed
exook opened this issue Nov 1, 2023 · 2 comments
Closed

Not able to run without profiling master branch #322

exook opened this issue Nov 1, 2023 · 2 comments
Labels
High Priority High priority items

Comments

@exook
Copy link
Contributor

exook commented Nov 1, 2023

Describe the bug
Master branch can only run with profiling enabled.

To Reproduce

  1. Checkout and pull latest master branch
  2. poetry run baler --project public_datasets hurricane_transformed --mode train

Expected behavior
After training completes you are presented with the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/pekman/baler/baler/baler.py", line 66, in main
    check_enabled_profilers(
  File "/home/pekman/baler/baler/baler.py", line 125, in check_enabled_profilers
    return outer_function(lambda: inner_function(f, *args, **kwargs))()
TypeError: 'NoneType' object is not callabl

System Information
Ubuntu 20.04

@exook
Copy link
Contributor Author

exook commented Nov 1, 2023

@AkkiG2401 Can you have a look at this ASAP?

@exook exook added the High Priority High priority items label Nov 1, 2023
@fritjof-b
Copy link
Contributor

fritjof-b commented Nov 1, 2023

A quickfix would be to explicitly add a check to the return value for the following snippet in baler.py

def check_enabled_profilers(
    f, pytorchProfile=False, energyProfile=False, *args, **kwargs
):
    """
    Conditionally apply profiling based on the given boolean flags.

    Args:
        f (callable): The function to be potentially profiled.
        pytorchProfile (bool): Whether to apply PyTorch profiling.
        energyProfile (bool): Whether to apply energy profiling.

    Returns:
        result: The result of the function `f` execution.
    """

    # Placeholder function to avoid nested conditions
    def identity_func(fn, *a, **kw):
        return fn(*a, **kw)

    # Set the outer and inner functions based on the flags
    inner_function = pytorch_profile if pytorchProfile else identity_func
    outer_function = (
        (
            lambda fn: energy_profiling(
                fn, project_name="baler_training", measure_power_secs=1
            )
        )
        if energyProfile
        else identity_func
    )
    
    # Suggestion
    retval = outer_function(lambda: inner_function(f, *args, **kwargs))
    retval = retval if retval else some_other_function


    return retval()
    # End suggestion
    ```

AkkiG2401 added a commit to AkkiG2401/baler that referenced this issue Nov 1, 2023
fritjof-b pushed a commit that referenced this issue Nov 2, 2023
@github-project-automation github-project-automation bot moved this from 🔲 Todo to ✅ Done in Baler Development Nov 2, 2023
OscarrrFuentes pushed a commit to OscarrrFuentes/baler that referenced this issue Oct 15, 2024
OscarrrFuentes pushed a commit to OscarrrFuentes/baler that referenced this issue Nov 21, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
High Priority High priority items
Projects
Archived in project
Development

No branches or pull requests

2 participants