Get service addon version and init service

Hi i am trying to run a service in docker, but i am not able to get the version of the current addon, how do i get the current version of the addon?

Hello,
As far as I know, every service gets a ServiceContext which can be accessed via ayon_api.

Here’s a snippet from kitsu addon

i tried this, but i keep getting
ValueError: Service is not initialized
this is the code i ran

ayon_api.init_service()
addon_name = ayon_api.get_service_addon_name()
addon_version = ayon_api.get_service_addon_version()
settings = ayon_api.get_service_addon_settings()
entrypoint = f"/addons/{addon_name}/{addon_version}"
print(entrypoint)

I don’t think you are initializing the service properly.
initializing can be done in two ways:

  1. Provide arguments for init_service.
  2. Set environment variables.
  • as far as I know, services on ASH run with env variables preconfigured.
  • also, we running the service locally for development purposes we use manage.ps1 or Makefile which configure the env variables properly before running the service script.

have a look on the init_service method to know more.

Ok this seems to get me somewhere, i see i dont have those attributes in the env, if i add it manually i do get the code to work, i will try see how to add those to the docker build, I will try this and let you know if i face any further issues.
Thanks

Most probable, you’d like to check manage.ps1 or makefile from different repos. here’s manage.ps1 from kitsu addon.

sure mustafa, thanks for the help.