community
cancel
Showing results for 
Search instead for 
Did you mean: 

Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!
SOLVED

SnakePlane suggestion: Add get_constant to 'logger' or generic 'alteryx_engine' namespace

Highlighted
Comet

While working on a recent tool using SnakePlane, I needed a temp directory for files. While I ended up using the Python tempfile package instead, I tried finding the TempFilePath workflow constant at one point.

 

It appears that the alteryx_engine inside AyxPlugin is hidden from the 'pilot', and as such, the output_message method is only exposed to the 'pilot' through the logger. So to get access to get_constant method, I added it temporarily to the self.logging SimpleNamespace following the pattern, and was able to use the following in Pdb:

 

(Pdb) logger.get_constant(0)
('Engine.GuiInteraction', '', '0', False)
(Pdb) logger.get_constant(1)
('Engine.IterationNumber', '', '0', True)
(Pdb) logger.get_constant(2)
('Engine.ModuleDirectory', '', 'C:\\Users\\<user>\\Documents\\~Alteryx\\snakeplane-master\\pilot\\debug_workflows\\', False)
(Pdb) logger.get_constant(3)
('Engine.TempFilePath', '', 'C:\\Users\\<user>\\AppData\\Local\\Temp\\Engine_7016_d592e2b9ab1c4a87b2c08afb64a01e81_\\', False)
(Pdb) logger.get_constant(4)
('Engine.Version', '', '2019.2.5.62427', False)
(Pdb) logger.get_constant(5)
('Engine.WorkflowDirectory', '', 'C:\\Users\\<user>\\Documents\\~Alteryx\\snakeplane-master\\pilot\\debug_workflows\\', False)
(Pdb) logger.get_constant(6)
('Engine.WorkflowFileName', '', './debug_workflows/SFTPInput.yxmd', False)

 

Does alteryx_engine need to be hidden in this fashion? If so, can we add some more features of the engine to either the logger, or a new SimpleNamespace? When I check dir(sdk.AlteryxEngine) I see the following methods that could be valuable to 'pilot':

 

[..., 'create_connect_metadata', 'create_temp_file_name', 'debug_message_out', 'decrypt_password', 'field_conversion_error_limit', 'get_constant', 'get_init_var', 'output_message', 'output_tool_progress', 'pre_sort', 'xmsg']

 

Several of these look indispensable!

 

The change to helper_classes for get_constant was simple enough:

 

            ...
            get_constant=partial(
                self._engine_vars.alteryx_engine.get_constant,
                self._engine_vars.n_tool_id,
            ),
            ...

 

If I can figure out how to submit a pull request on github ... I'll try it out.

Moderator
Moderator

Hi @c2willis - can you post this as an issue in the snakeplane GitHub repo? It will get more traction with the team who manages it. Thanks! 

Comet

Done!