Hi @HaveF , a component can be considered as what a function is in programming languages, so they do not usually have a link to a file, but rather would take input parameters - either some data that can be read from a file, or perhaps a link to a file path (as data row or as a variable).
While some components can have some data, for example a list for mapping, this can be stored in a table within the component.
Can you tell us a bit more what your component is doing, and how the file you want to attach to it is related to the component?
@HaveF you can use the data directory of you share the whole workflow. If you want static data to be shared you could create the data in a script or with the
Yes, component is a function, and it is a pure function
Here is my case:
I want to use some Java Jar file in Java Snippet as additional libraries, I donât know where to put them If I want to make this part as a component.
Of course I can put it on some specific positions, but if I want to share the component with others, like on KNIME hub, it seems I still tell others to download jar file, and put it some where. It just looks awkward.
@HaveF I have created an example like this. You have a code as a string and dynamically write that to a (temporary) folder and use that as a source. The example is about a Python code. Maybe you can adapt that.
Hi @mlauber71 , thanks for the hint. Itâs an interesting solution for portable Python code.
Please forgive me for being picky at first.
Your example is an example of using the same node to run on different platforms.
What I want is an example of using the same component in different workflows.
As I said before:
I want to use some Java jar file in Java Snippet as additional libraries and build it as a component.
I want to use this component in different workflows.
It seems a working solution is to dynamically download the jar file in the component, then use the jar file in Java Snippet. It feels a bit clumsy, but it seems to be the only way.
Sometimes I stick to clear and best practices. Sorry for being picky again
@HaveF no worries discussing ideas and selecting the best is one aim of this forum. If you can savely provide a Component or a JAR file on a central storage this might be the best solution. If people would load a whole workflow you might be able to use the /data/ folder. In the other thread there were suggestions of putting the (Python) code on a repository - you also might think about a company repository (with JFrog/Artifactory or something similar).
The thing with dynamically creating a .PY file from a KNIME node and reading that back is more like a hack to have everything within KNIME nodes. Might not really be a serious option, more to demonstrate that if you have restrictions you still could do this
Hi @HaveF ahhh, jar files⊠this is certainly a good use case. I chose not to create public components if they were dependent on jar files. For internal usage, that is components that gonna run on the same machine, such as in your case where you simply want to reuse the component in the same workflow and to benefit from the âauto-updateâ when updating the component, then you can leave the path to the jar file hardcoded inside the component. The component itself does not need to include the jar file, as long as the jar file exists at the path itâs pointing to.
Alternatively, there are some libraries that come with Knime, and if the jar file you wanted to include already comes with Knime, then you donât have to include the jar file and simply configure your Java Snippet to use it (or multiple ones).
You can do this in the âAdditional Bundlesâ tab in the Java Snippet node:
You can add from the Bundles that are available. One of the libraries that I used a lot is the Apache Commons for encoding. Just look for it in the Bundles list and then add it:
Once you add it, you will see it added in the top section:
Hi @HaveF , but isnât this applicable to anything we do within the component? Nodes deprecated, etc. But thatâs the beauty of the using components, where you can update the component, and any workflow thatâs linked to the component will be updated