@erick_cheng I think the only problem with pretty_json is the import needs modified just a bit. It should instead be ["pretty-json"] with a hyphen instead of underscore. Once that is updated in your connection the import should work!
def run(params={}):
from pretty_json import format_json
return {"output": format_json({'key': 'value'})}
I figured out why the 3rd party modules aren’t working - the modules are installing on the wrong plugin version.
Modules are installing on 2.0.1 but workflows are running on 2.0.2. I was able to confirm this by execing into the respective docker containers and running pip list.
When searching and selecting a plugin, you have the ability to select which version will be used:
Since the Python 3 dependencies are part of the connection configuration, you’ll want to make sure whatever connection is being used by the plugin has the necessary dependencies defined. It sounds like the actions in your workflow are using version 2.0.2 and don’t have a connection with the necessary dependencies defined.
Great, I was able to get a 2.0.2 connection by creating a new one. Is there no way to upgrade an existing connection? It’ll be a hassle if we need to update all of our workflows every time there’s a new plugin version.
Btw, do you know how to log messages? It’ll be useful for debugging.
I’ve followed the docs here but its not working:
To log messages with the Python plugin, import logging and call logging.info() or other logging methods in the run function. print or equivalent statements will not successfully log messages due to how output is handled by the plugin.
Is there no way to upgrade an existing connection?
If the plugin version update is a minor or patch (1.X.0 or 1.0.X) it’s pretty painless. The major patch versions (X.0.0) indicate the input or output changed, so they’re a little more painful to update.
Btw, do you know how to log messages? It’ll be useful for debugging.
Following up on what @joey_mcadams added about the logger. Currently when logging with the Python plugin, the message can be found within the container logs (eg. docker logs <CONTAINER_ID>); however, they won’t be returned in the step output within the InsightConnect UI. We’re doing a bit of digging to see how we can best facilitate this.