Quantcast
Channel: Node Development - KNIME Community Forum
Viewing all articles
Browse latest Browse all 81

Using knext.MultiColumnParameter

$
0
0

Hi there,

I am currently working on a rather simple node that aims to be able to streamline date formats across multiple columns.

The node works for now as intended, except for 2 points.

To illustrate the matter, here is a picture of the test table:

Here is a picture of the config panel:

The first one is not that important, but just to mention it in case someone has a brilliant simple idea, there is an option to convert the dates back to String format, and if not ticked, the format will be Local Date Time. If that option is unchecked, there is a warning : DataSpec generated by configure does not match spec after execution.
Which is logical as the column types are different and my configure just returns the input table schema.

The second and more important issue is that I can get the MultiColumnParameter to work, and the documentation doesn’t provide much help here.
Here is my variable definition in the DateNode class:

class DateNode:  
...
  selected_columns = knext.MultiColumnParameter(
      label="Specify Dates Columns",
      description="Select the columns that should be filtered out."
  )
  
  def configure(self, config_context, input_table_schema):
      # the multiple column selection parameter needs to be provided the list of columns of an input table
      self.selected_columns = input_table_schema.column_names
      return input_table_schema
  
  def execute(self, exec_context, input_table):
  
      df = input_table.to_pandas()
  
      selected_cols = self.selected_columns

      df_processed = streamline_dates_processing_v7(df.copy(), selected_cols, to_string=to_string, to_replace=to_replace, date_formats_list=date_formats_list, string_output_format=string_output_format)

      return knext.Table.from_pandas(df_processed)

Obviously nothing happens here, but I used some loggers around to try and get at which point, or under which variable or attribute my column selection list appears, and I couldn’t find any, whether in the configure or the execute method.

I only need the list of columns, in order to pass this as an argument to my function (my function takes a dataframe, takes multiple arguments including a columns list to which it will apply the script), and for the life of my I can’t find how to retrieve it from the attribute (or I’m dumb and/or blind, which is also very possible).

Any help would be greatly appreciated :slight_smile:

Regarding the first issue, if someone has a brilliant idea to remove that warning if the column types are different (I can’t really specify them manually in the return schema as I can’t know which columns and which types will be returned).

Thanks!

6 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 81

Trending Articles