Skip to content

Commit

Permalink
Merge pull request #136 from XpressAI/adry/add-import-component
Browse files Browse the repository at this point in the history
✨Add component that enable to add import
  • Loading branch information
MFA-X-AI authored Apr 4, 2022
2 parents aabafe2 + 6c15c66 commit 3c573a9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/components/xircuitBodyWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,17 @@ export const BodyWidget: FC<BodyWidgetProps> = ({
let current_node: any;
let package_name: string = "components";

const addImportNode = getNodeModelByName(nodeModels, 'AddImport');
if (componentName == 'AddImport') {
const importPortName = addImportNode['portsIn'][1].getOptions()['name']
const getImportPortLinks = addImportNode.getPorts()[importPortName].getLinks();
for (let portLink in getImportPortLinks) {
// Add value of import_str port for importing
const importLabel = getImportPortLinks[portLink].getSourcePort().getOptions()["label"];
pythonCode += importLabel + "\n";
}
}

if (component_exist != -1) {
current_node = componentList[component_exist];
package_name = current_node["package_name"];
Expand Down
14 changes: 13 additions & 1 deletion xai_components/xai_template/example_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,16 @@ def execute(self, ctx) -> None:

print(f"After Adding Context:\n{ctx}")

self.done = True
self.done = True

@xai_component(color="red")
class AddImport(Component):
import_str: InArg[str]

def __init__(self):
self.import_str = InArg.empty()
self.done = False

def execute(self, ctx) -> None:

self.done = True

0 comments on commit 3c573a9

Please sign in to comment.