Help with my first klipper extra

import requests
from klipper import connect

class dynamicvariables:
    def __init__(self, config):
        self.printer = config.get_printer()
        self.reactor = self.printer.get_reactor()
        self.gcode = self.printer.lookup_object('gcode')
        self.printer.register_event_handler("print_start", self.on_print_start)
        self.metadata = {}

    @classmethod
    def get_moonraker_metadata(cls, filename, moonraker_url="http://localhost:7125"):
        url = f"{moonraker_url}/server/files/metadata?filename={filename}"
        try:
            response = requests.get(url)
            response.raise_for_status()  # Raise an exception for error HTTP statuses

            data = response.json()
            return data['result']
        except requests.exceptions.RequestException as e:
            print(f"Error fetching metadata: {e}")
            return None

    def on_print_start(self, event_time):
        filename = event_time['file']
        self.metadata = self.get_moonraker_metadata(filename)

def load_config(config):
    return dynamicvariables(config)

I have this file saved as “dynamicvariables.py” in the /klipper/klippy/extras folder.
When trying to load it via cfg file, I just receive the following error:

Section 'dynamicvariables' is not a valid config section

What am I doing wrong?

no idea what I am talking about, but that’s never stopped me before!

Q: where is ‘config’ defined? What is it supposed to point to?

I’m risking it’s a dumb reply because I truly do not know, but I do not see config being set to anything.

Good luck!

Did you restart Klipper via the RESTART command, or with sudo service klipper restart? You need to restart the service (sudo service klipper restart) anytime you modify an extra.

Did a full restart of the pi.

I’m not sure why that line is there, but it doesn’t seem to be doing anything and may be the cause of an error.

removing that line, made no difference