cloe icon indicating copy to clipboard operation
cloe copied to clipboard

Plugins only recognized if defined in last json file

Open c276 opened this issue 3 years ago • 2 comments

Given the following 3 config files:

  • first_cloe_config.json:
{
  "version": "4",
  "include": ["second_cloe_config.json"]
}
  • second_cloe_config.json:
{
  "version": "4",
  "include": ["third_cloe_config.json"],
  "plugins": [
    {
      "path": "path/to/my_plugin.so"
    }
  ]
}
  • third_cloe_config.json:
{
  "version": "4",
(...)
}

When calling cloe-engine run first_cloe_config.json, the plugin defined in second_cloe_config.json is not recognized. The same happens if I define the plugin in first_cloe_config.json However, if I define the plugin in third_cloe_config.json, the plugin is recognized. Is this desired behavior?

c276 avatar Mar 29 '22 12:03 c276

Hi @c276, thanks for raising this issue! When you say, "is not recognized", what do mean?

  • Is the plugin ignored?
  • Is the plugin not found?
  • Are you using relative paths for your plugin?
  • See the output of cloe-engine dump first_cloe_config.json to check your assumptions.

Note that if you are using a relative path in your config file, it is relative from the config file that specifies it.

cassava avatar Apr 25 '22 14:04 cassava

Hi @cassava, thanks for your reply. I'll try to make the issue clearer: With "is not recognized", I mean it is not loaded and it is not attempted to be loaded. Also, I use absolute paths. I enhanced my example files to show the error:

  • I moved controller_basic.so from /usr/local/lib/cloe (where I installed cloe) to /urs/local/lib so that it is not recognized by cloe automatically
  • All config files are at the same location.
  • first_cloe_config.json:
{
    "version": "4",
    "include": [
        "second_cloe_config.json"
    ],
    "simulators": [
        {
            "binding": "minimator",
            "args": {
                "vehicles": [
                    "ego"
                ]
            }
        }
    ],
    "vehicles": [
        {
            "name": "default",
            "from": {
                "simulator": "minimator",
                "index": 0
            }
        }
    ],
    "server": {
        "listen": false
    }
}
  • second_cloe_config.json:
{
    "version": "4",
    "include": [
        "third_cloe_config.json"
    ],
    "plugins": [
        {
            "path": "/usr/local/lib/controller_basic.so"
        }
    ]
}
  • third_cloe_config.json:
{
    "version": "4",
    "controllers": [
        {
            "binding": "basic",
            "vehicle": "default"
        }
    ],
    "triggers": [
        {
            "event": "start",
            "action": "log=info: Running smoketest."
        },
        {
            "event": "start",
            "action": "realtime_factor=-1"
        },
        {
            "event": "time=${DURATION-10}",
            "action": "succeed"
        }
    ],
    "logging": [
        {
            "name": "basic",
            "level": "trace"
        }
    ]
}
  • output (at location of config files):
❯ cloe-engine dump first_cloe_config.json
third_cloe_config.json:/controllers/0: unknown factory: basic
    In JSON segment:
        {
          "binding": "basic",
          "vehicle": "default"
        }
    With following JSON schema:
        {
          "oneOf": [
            {
              "additionalProperties": false,
              "properties": {
                "args": null,
                "binding": {
                  "const": "demo_printer",
                  "description": "name of factory"
                },
                "name": {
                  "description": "globally unique identifier for controller",
                  "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
                  "type": "string"
                },
                "vehicle": {
                  "description": "vehicle controller is assigned to",
                  "type": "string"
                }
              },
              "required": [
                "binding"
              ],
              "type": "object"
            },
            {
              "additionalProperties": false,
              "properties": {
                "args": {
                  "additionalProperties": false,
                  "properties": {
                    "halt_progress_at": {
                      "description": "time in ns at which to halt all progress",
                      "maximum": 9223372036854775807,
                      "minimum": -9223372036854775808,
                      "type": "integer"
                    },
                    "progress_per_step": {
                      "description": "progress to make each step",
                      "maximum": 9223372036854775807,
                      "minimum": -9223372036854775808,
                      "type": "integer"
                    }
                  },
                  "type": "object"
                },
                "binding": {
                  "const": "demo_stuck",
                  "description": "name of factory"
                },
                "name": {
                  "description": "globally unique identifier for controller",
                  "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
                  "type": "string"
                },
                "vehicle": {
                  "description": "vehicle controller is assigned to",
                  "type": "string"
                }
              },
              "required": [
                "binding"
              ],
              "type": "object"
            },
            {
              "additionalProperties": false,
              "properties": {
                "args": {
                  "additionalProperties": false,
                  "properties": {
                    "components": {
                      "description": "array of components to be extracted",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "output_file": {
                      "description": "file path to write groundtruth output to",
                      "type": "string"
                    },
                    "output_type": {
                      "description": "type of output file to write",
                      "enum": [
                        "json.bz2",
                        "json.gz",
                        "json.zip",
                        "json",
                        "msgpack.bz2",
                        "msgpack.gz",
                        "msgpack.zip",
                        "msgpack"
                      ],
                      "type": "string"
                    }
                  },
                  "type": "object"
                },
                "binding": {
                  "const": "gndtruth_extractor",
                  "description": "name of factory"
                },
                "name": {
                  "description": "globally unique identifier for controller",
                  "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
                  "type": "string"
                },
                "vehicle": {
                  "description": "vehicle controller is assigned to",
                  "type": "string"
                }
              },
              "required": [
                "binding"
              ],
              "type": "object"
            },
            {
              "additionalProperties": false,
              "properties": {
                "args": null,
                "binding": {
                  "const": "nop",
                  "description": "name of factory"
                },
                "name": {
                  "description": "globally unique identifier for controller",
                  "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
                  "type": "string"
                },
                "vehicle": {
                  "description": "vehicle controller is assigned to",
                  "type": "string"
                }
              },
              "required": [
                "binding"
              ],
              "type": "object"
            },
            {
              "additionalProperties": false,
              "properties": {
                "args": {
                  "additionalProperties": false,
                  "properties": {
                    "init_phase": {
                      "description": "time during which initialization is performed",
                      "maximum": 9223372036854775807,
                      "minimum": -9223372036854775808,
                      "type": "integer"
                    },
                    "lane_sensor_components": {
                      "description": "array of lane-sensor components to be checked",
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                },
                "binding": {
                  "const": "virtue",
                  "description": "name of factory"
                },
                "name": {
                  "description": "globally unique identifier for controller",
                  "pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$",
                  "type": "string"
                },
                "vehicle": {
                  "description": "vehicle controller is assigned to",
                  "type": "string"
                }
              },
              "required": [
                "binding"
              ],
              "type": "object"
            }
          ]
        }

However, if I move the plugin definition in the third file, it works:

  • second_cloe_config.json:
{
    "version": "4",
    "include": [
        "third_cloe_config.json"
    ]
}
  • third_cloe_config.json
{
    "version": "4",
    "plugins": [
        {
            "path": "/usr/local/lib/controller_basic.so"
        }
    ],
    "controllers": [
        {
            "binding": "basic",
            "vehicle": "default"
        }
    ],
    "triggers": [
        {
            "event": "start",
            "action": "log=info: Running smoketest."
        },
        {
            "event": "start",
            "action": "realtime_factor=-1"
        },
        {
            "event": "time=${DURATION-10}",
            "action": "succeed"
        }
    ],
    "logging": [
        {
            "name": "basic",
            "level": "trace"
        }
    ]
}
  • output:
❯ cloe-engine dump first_cloe_config.json
{
  "controllers": [
    {
      "binding": "basic",
      "vehicle": "default"
    }
  ],
  "defaults": {
    "components": [],
    "controllers": [],
    "simulators": []
  },
  "engine": {
    "hooks": {
      "post_disconnect": [],
      "pre_connect": []
    },
    "ignore": [],
    "keep_alive": false,
    "output": {
      "clobber": true,
      "files": {
        "config": "config.json",
        "result": "result.json",
        "triggers": "triggers.json"
      },
      "path": "${CLOE_SIMULATION_UUID}"
    },
    "plugin_path": [
      "/usr/local/lib/cloe",
      "/usr/lib/cloe"
    ],
    "plugins": {
      "allow_clobber": true,
      "ignore_failure": false,
      "ignore_missing": false
    },
    "polling_interval": 100,
    "registry_path": "/home/dockeruser/.local/share/cloe/registry",
    "security": {
      "enable_command_action": false,
      "enable_hooks_section": true,
      "enable_include_section": true,
      "max_include_depth": 64
    },
    "triggers": {
      "ignore_source": false
    },
    "watchdog": {
      "default_timeout": 90000,
      "mode": "off",
      "state_timeouts": {
        "ABORT": 90000,
        "CONNECT": 300000,
        "DISCONNECT": 600000,
        "STOP": 300000
      }
    }
  },
  "logging": [
    {
      "level": "trace",
      "name": "basic"
    }
  ],
  "plugins": [
    {
      "path": "/usr/local/lib/controller_basic.so"
    }
  ],
  "server": {
    "api_prefix": "/api",
    "listen": false,
    "listen_address": "127.0.0.1",
    "listen_port": 8080,
    "listen_threads": 10,
    "static_prefix": ""
  },
  "simulation": {
    "abort_on_controller_failure": true,
    "controller_retry_limit": 1000,
    "controller_retry_sleep": 1,
    "model_step_width": 20000000
  },
  "simulators": [
    {
      "args": {
        "vehicles": [
          "ego"
        ]
      },
      "binding": "minimator"
    }
  ],
  "triggers": [
    {
      "action": "log=info: Running smoketest.",
      "event": "start",
      "source": "filesystem",
      "sticky": false
    },
    {
      "action": "realtime_factor=-1",
      "event": "start",
      "source": "filesystem",
      "sticky": false
    },
    {
      "action": "succeed",
      "event": "time=10",
      "source": "filesystem",
      "sticky": false
    }
  ],
  "vehicles": [
    {
      "components": {},
      "from": {
        "index": 0,
        "simulator": "minimator"
      },
      "name": "default"
    }
  ],
  "version": "4"
}

c276 avatar Apr 26 '22 07:04 c276