Skip to content

[PLUGIN-1792] Enable macro for plugin config script#26

Merged
psainics merged 1 commit intodata-integrations:developfrom
cloudsufi:feat/macro-script
Jul 23, 2024
Merged

[PLUGIN-1792] Enable macro for plugin config script#26
psainics merged 1 commit intodata-integrations:developfrom
cloudsufi:feat/macro-script

Conversation

@psainics
Copy link
Copy Markdown
Contributor

Enable macro for plugin config script

Jira : PLUGIN-1792

Description

This PR makes the plugin config script a macro.

  • Demo
    image

Code change

  • Modified PythonEvaluator.java

@psainics psainics changed the title Enable macro for plugin config script [PLUGIN-1792] Enable macro for plugin config script Jun 13, 2024
@psainics psainics force-pushed the feat/macro-script branch from c154e08 to 67af410 Compare June 26, 2024 03:31
@aviachar aviachar requested a review from itsankit-google July 3, 2024 06:33
// try evaluating the script to fail application creation
// if the script is invalid (only possible for interpreted mode)
if (config.executionMode.equalsIgnoreCase(EXECUTION_MODE_INTERPRETED)) {
if (config.executionMode != null && config.executionMode.equalsIgnoreCase(EXECUTION_MODE_INTERPRETED)) {
Copy link
Copy Markdown

@itsankit-google itsankit-google Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add a check here that script is not macro before we try to compile it in JythonPythonExecutor

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (config.executionMode != null &&
    !config.containsMacro(Config.SCRIPT) &&
    config.executionMode.equalsIgnoreCase(EXECUTION_MODE_INTERPRETED)) 

Copy link
Copy Markdown

@itsankit-google itsankit-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a unit test

@psainics
Copy link
Copy Markdown
Contributor Author

psainics commented Jul 3, 2024

Please add a unit test

Is there api for testing macro ?

@psainics psainics requested a review from itsankit-google July 3, 2024 09:35
// try evaluating the script to fail application creation
// if the script is invalid (only possible for interpreted mode)
if (config.executionMode.equalsIgnoreCase(EXECUTION_MODE_INTERPRETED)) {
if (config.executionMode != null &&
Copy link
Copy Markdown

@itsankit-google itsankit-google Jul 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!containsMacro(config.executionMode)

We should also throw validation exception if executionMode is null:

private static final String EXECUTION_MODE = "executionMode";
if (!containsMacro(config.EXECUTION_MODE) && Strings.isNullOrEmpty(config.executionMode)) {
.....
return;
}

if (!config.containsMacro(config.EXECUTION_MODE) && !config.containsMacro(Config.SCRIPT) &&
        config.executionMode.equalsIgnoreCase(EXECUTION_MODE_INTERPRETED)) {
      try {
        new JythonPythonExecutor(config).initialize(null);
      } catch (IOException | InterruptedException e) {
        collector.addFailure("Could not compile script: " + e.getMessage(), null)
          .withStacktrace(e.getStackTrace()).withConfigProperty(Config.SCRIPT);
      }
    }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated !

@psainics psainics merged commit 92f472a into data-integrations:develop Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants