Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

Commit

Permalink
fix path related bug (#70)
Browse files Browse the repository at this point in the history
Co-authored-by: smahmed776 <[email protected]>
  • Loading branch information
flojoy-bot[bot] and smahmed776 authored Jun 10, 2023
1 parent ef90ac2 commit a5a9f73
Show file tree
Hide file tree
Showing 23 changed files with 650 additions and 54 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
subset:
type: select
options:
- train
- test
- all
default: train
categories:
type: array
default: ''
remove_headers:
type: boolean
default: false
type: array
remove_footers:
default: false
type: boolean
remove_headers:
default: false
remove_quotes:
type: boolean
remove_quotes:
default: false
type: boolean
subset:
default: train
options:
- train
- test
- all
type: select
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import pandas as pd
from typing import cast


# TODO: Add more datasets to this node.
@flojoy
def TEXT_DATASET(dc_inputs: list[DataContainer], params: dict) -> DataContainer:


subset = params.get("subset", "train")
categories = params.get("categories", None)
remove_headers = params.get("remove_headers", False)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import json
import os
from datetime import datetime
import requests
from flojoy import DataContainer, flojoy
from flojoy.utils import PlotlyJSONEncoder, get_frontier_api_key

FRONTIER_URI: str = (
os.environ.get("FRONTIER_URI")
or "https://cipfsgeml2.execute-api.us-east-1.amazonaws.com"
)
MEASUREMENT_API: str = f"{FRONTIER_URI}/measurements"
FRONTIER_URI: str = os.environ.get("FRONTIER_URI") or "https://frontier-next.vercel.app"
MEASUREMENT_API: str = f"{FRONTIER_URI}/api/streaming"


@flojoy
Expand All @@ -20,13 +16,11 @@ def LOADER(dc_inputs: list[DataContainer], params: dict) -> DataContainer:
if api_key is not None and measurement_uuid != "":
try:
requests.post(
f"{MEASUREMENT_API}/{measurement_uuid}",
MEASUREMENT_API,
json={
"api_key": api_key,
"measurements": json.dumps(
{"data": dc_inputs[0]}, cls=PlotlyJSONEncoder
),
"time": datetime.now().__str__(),
"measurement_id": measurement_uuid,
"measurement": json.dumps(dc_inputs[0], cls=PlotlyJSONEncoder),
},
)
except Exception as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,7 @@ import pandas as pd
def OPEN_MATLAB(
dc_inputs: list[DataContainer], params: dict
) -> Union[DataContainer, dict]:
"""The OPEN_MATLAB node loads a local file of the .mat file format.
Note that if multiple 'tabs' of data are used, the number of rows
must match in order to stack the arrays.

Parameters
----------
file_path : str
path to the file to be loaded.

Returns:
--------
DataContainer:
type 'dataframe', m
"""

file_path: str = params["path"]

if file_path == "":
Expand All @@ -47,4 +34,3 @@ def OPEN_MATLAB(
df = pd.DataFrame(np.hstack((X, Y)))

return DataContainer(type="dataframe", m=df)

188 changes: 188 additions & 0 deletions docs/nodes/TRANSFORMERS/ARITHMETIC/SUBTRACT/examples/EX1/app.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
{
"rfInstance": {
"nodes": [
{
"width": 190,
"height": 115,
"id": "END-06a4da40-a0ae-44ad-873b-9b65d096880a",
"type": "TERMINATOR",
"data": {
"id": "END-06a4da40-a0ae-44ad-873b-9b65d096880a",
"label": "END",
"func": "END",
"type": "TERMINATOR",
"ctrls": {},
"selected": true
},
"position": {
"x": 1481.1276538172046,
"y": 301.7443219065692
},
"selected": true,
"positionAbsolute": {
"x": 1481.1276538172046,
"y": 301.7443219065692
},
"dragging": true
},
{
"width": 150,
"height": 135,
"id": "LINSPACE-b70dcbec-87fc-47bd-98dc-26c01de91881",
"type": "default",
"data": {
"id": "LINSPACE-b70dcbec-87fc-47bd-98dc-26c01de91881",
"label": "LINSPACE",
"func": "LINSPACE",
"type": "SIMULATION",
"ctrls": {
"start": {
"functionName": "LINSPACE",
"param": "start",
"value": "10"
},
"end": {
"functionName": "LINSPACE",
"param": "end",
"value": "0"
},
"step": {
"functionName": "LINSPACE",
"param": "step",
"value": "1000"
}
},
"selected": false
},
"position": {
"x": 335.60460405758,
"y": 414.5947652926823
},
"selected": false,
"positionAbsolute": {
"x": 335.60460405758,
"y": 414.5947652926823
},
"dragging": true
},
{
"width": 150,
"height": 135,
"id": "LINSPACE-0c193475-a070-4357-b9f6-1cc8320c8a65",
"type": "default",
"data": {
"id": "LINSPACE-0c193475-a070-4357-b9f6-1cc8320c8a65",
"label": "LINSPACE_1",
"func": "LINSPACE",
"type": "SIMULATION",
"ctrls": {
"start": {
"functionName": "LINSPACE",
"param": "start",
"value": "10"
},
"end": {
"functionName": "LINSPACE",
"param": "end",
"value": "0"
},
"step": {
"functionName": "LINSPACE",
"param": "step",
"value": "1000"
}
},
"selected": false
},
"position": {
"x": 337.2242660007536,
"y": 164.02507602827643
},
"selected": false,
"positionAbsolute": {
"x": 337.2242660007536,
"y": 164.02507602827643
},
"dragging": true
},
{
"width": 99,
"height": 115,
"id": "SUBTRACT-be7bf775-eca1-4008-9d78-7164cf815da0",
"type": "ARITHMETIC",
"data": {
"id": "SUBTRACT-be7bf775-eca1-4008-9d78-7164cf815da0",
"label": "SUBTRACT",
"func": "SUBTRACT",
"type": "ARITHMETIC",
"ctrls": {},
"inputs": [
{
"name": "y",
"id": "sub_y",
"type": "target"
}
],
"selected": false
},
"position": {
"x": 984.775645730269,
"y": 300.51837909623805
},
"selected": false,
"positionAbsolute": {
"x": 984.775645730269,
"y": 300.51837909623805
},
"dragging": true
}
],
"edges": [
{
"source": "SUBTRACT-be7bf775-eca1-4008-9d78-7164cf815da0",
"sourceHandle": "main",
"target": "END-06a4da40-a0ae-44ad-873b-9b65d096880a",
"targetHandle": "END",
"id": "reactflow__edge-SUBTRACT-be7bf775-eca1-4008-9d78-7164cf815da0main-END-06a4da40-a0ae-44ad-873b-9b65d096880aEND"
},
{
"source": "LINSPACE-0c193475-a070-4357-b9f6-1cc8320c8a65",
"sourceHandle": "main",
"target": "SUBTRACT-be7bf775-eca1-4008-9d78-7164cf815da0",
"targetHandle": "SUBTRACT",
"id": "reactflow__edge-LINSPACE-0c193475-a070-4357-b9f6-1cc8320c8a65main-SUBTRACT-be7bf775-eca1-4008-9d78-7164cf815da0SUBTRACT"
},
{
"source": "LINSPACE-b70dcbec-87fc-47bd-98dc-26c01de91881",
"sourceHandle": "main",
"target": "SUBTRACT-be7bf775-eca1-4008-9d78-7164cf815da0",
"targetHandle": "sub_y",
"id": "reactflow__edge-LINSPACE-b70dcbec-87fc-47bd-98dc-26c01de91881main-SUBTRACT-be7bf775-eca1-4008-9d78-7164cf815da0sub_y"
}
],
"viewport": {
"x": 296.7009684013002,
"y": 78.64846027544155,
"zoom": 0.8997754917401063
}
},
"ctrlsManifest": [
{
"type": "input",
"name": "Slider",
"id": "INPUT_PLACEHOLDER",
"hidden": false,
"minHeight": 1,
"minWidth": 2,
"layout": {
"x": 0,
"y": 0,
"h": 2,
"w": 2,
"minH": 1,
"minW": 2,
"i": "INPUT_PLACEHOLDER"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
In this example, we `SUBTRACT` the outputs of two identical `LINSPACE` nodes.

As expected, when we check the output of the app, we see 0 everywhere, as expected!
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,7 @@ from PIL import ImageFilter, Image

@flojoy
def EDGE_DETECTION(dc_inputs: list[DataContainer], params: dict) -> DataContainer:
"""The EDGE_DETECTION node detects edges in the image passed to it.
This is done through the the Pillow image filter FIND_EDGES.
Note that the image is converted to greyscale during this processing.

Parameters
----------
None

Returns
-------
image
The image with detected edges in white.
"""

dc_input = dc_inputs[0]
if dc_input.type != "image":
raise ValueError(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
In this example the edges of an image are detected using the `EDGE_DETECTION` node.

The image is loaded using the `LOCAL_FILE` node. In this case the default astronaut image.
ITS AN EDGE DETECTION APP WHICH USES AN EDGE DETECTION FILTER NODE TO DETECT EDGES ON AN IMAGE.
57 changes: 57 additions & 0 deletions docs/nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/ARRAY_VIEW.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

[//]: # (Custom component imports)

import DocString from '@site/src/components/DocString';
import PythonCode from '@site/src/components/PythonCode';
import Parameters from '@site/src/components/Parameters';
import AppDisplay from '@site/src/components/AppDisplay';
import SectionBreak from '@site/src/components/SectionBreak';
import AppendixSection from '@site/src/components/AppendixSection';

[//]: # (Docstring)

import DocstringSource from '!!raw-loader!./a1-[autogen]/docstring.txt';
import PythonSource from '!!raw-loader!./a1-[autogen]/python_code.txt';
import ParametersSource from '!!raw-loader!./a1-[autogen]/parameters.yaml';

<DocString>{DocstringSource}</DocString>
<PythonCode GLink='VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/ARRAY_VIEW.py'>{PythonSource}</PythonCode>
<Parameters>{ParametersSource}</Parameters>

<SectionBreak />



[//]: # (Examples)

## Examples

import Example1 from './examples/EX1/example.md';
import App1 from '!!raw-loader!./examples/EX1/app.txt';
import Data1 from '!!raw-loader!./examples/EX1/output.txt';

<AppDisplay
data={Data1}
nodeLabel='ARRAY_VIEW'>
{App1}
</AppDisplay>

<Example1 />

<SectionBreak />



[//]: # (Appendix)

import Notes from '!!raw-loader!./appendix/notes.md';
import Hardware from '!!raw-loader!./appendix/hardware.md';
import Media from '!!raw-loader!./appendix/media.md';

## Appendix

<AppendixSection index={0} folderPath='nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/appendix/'>{Notes}</AppendixSection>
<AppendixSection index={1} folderPath='nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/appendix/'>{Hardware}</AppendixSection>
<AppendixSection index={2} folderPath='nodes/VISUALIZERS/DATA_STRUCTURE/ARRAY_VIEW/appendix/'>{Media}</AppendixSection>


Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

The ARRAY_VIEW node takes "ordered_pair", "dataframe", "matrix", and "image" as input type
and displays its visualization in array format.

Parameters
----------
None

Returns
-------
plotly
Visualization of the input data in array format
Loading

0 comments on commit a5a9f73

Please sign in to comment.