cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Python Extension 2.0 - read from JSON config file

Jan_VanBelle
Contributor

Hello,

Our custom python plugins (EF1) often have JSON files included which contain a huge part of config settings

  • urls to check
  • folders to check
  • team configurations
  • ...

I just wonder how to import/migrate those files into the EF2 equivalent of the plugins.
I noticed they are never included in the compiled packages and thus give an error when trying to access them.

Jan_VanBelle_0-1722343305458.png

Now testing with various settings in the 'setup.py', but no results so far

Thanks for the ideas/feedback

Jan

2 REPLIES 2

TomásSeroteRoos
Dynatrace Helper
Dynatrace Helper

You will have to include package_data in your setup.py file, as illustrated in the setuptools docs.

So if your directory structure looks like this:

  • extension_folder/
    • setup.py
    • extension/
      • extension.yaml
    • servicebus_plugin/
      • __init__.py
      • __main__.py
      • config/
        • my_file.json
        • another_file.json

You would want to have something like this in your setup.py file:

setup(name="servicebus_plugin",
      version=find_version(),
      description="Demo plugin for community",
      author="You :)",
      packages=find_packages(),
      package_data={"servicebus_plugin": [
          "config/*.json"
      ]},
      python_requires=">=3.10",
      include_package_data=True,
      install_requires=["dt-extensions-sdk"],
      extras_require={"dev": ["dt-extensions-sdk[cli]"]},
      )

 

Jan_VanBelle
Contributor

Hello, sorry for the delay
Indeed, that's something that seems to work!
except the wildcard (config/*.json) was not accepted, so I added all the config files 1 by 1.

Thanks,

Jan

Featured Posts