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

Commit

Permalink
Merge branch 'dallas/blo-151-afg31000' of https://github.com/flojoy-a…
Browse files Browse the repository at this point in the history
…i/blocks into dallas/blo-151-afg31000
  • Loading branch information
dstrande committed Dec 5, 2023
2 parents 9648a60 + 3c88d4e commit b4fcfe2
Show file tree
Hide file tree
Showing 390 changed files with 17,969 additions and 1,471 deletions.
6 changes: 3 additions & 3 deletions blocks/AI_ML/AUDIO/SPEECH_2_TEXT/SPEECH_2_TEXT.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flojoy import flojoy, DataContainer, TextBlob, File
from flojoy import flojoy, DataContainer, String, File
from typing import Optional
from huggingsound import SpeechRecognitionModel

Expand All @@ -17,7 +17,7 @@ def SPEECH_2_TEXT(
Returns
-------
TextBlob
String
Filename and path of the recording.
"""
file_path = file_path.unwrap() if file_path else None
Expand All @@ -26,4 +26,4 @@ def SPEECH_2_TEXT(
audio_paths = [file_path]
transcriptions = model.transcribe(audio_paths)

return TextBlob(text_blob=transcriptions[0]["transcription"])
return String(s=transcriptions[0]["transcription"])
4 changes: 2 additions & 2 deletions blocks/AI_ML/AUDIO/SPEECH_2_TEXT/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob|Boolean",
"type": "String|Boolean",
"multiple": false,
"desc": "The DataContainer to be visualized in text format"
}
Expand All @@ -213,7 +213,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"desc": "The DataContainer containing text data"
}
],
Expand Down
2 changes: 1 addition & 1 deletion blocks/AI_ML/AUDIO/SPEECH_2_TEXT/block_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"returns": [
{
"name": null,
"type": "TextBlob",
"type": "String",
"description": "Filename and path of the recording."
}
]
Expand Down
6 changes: 3 additions & 3 deletions blocks/COMPUTER_VISION/EDGE_DETECTION/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"multiple": false,
"desc": "the DataContainer to be visualized in text format"
}
Expand Down Expand Up @@ -254,8 +254,8 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"desc": "text_blob: return the value being set in Parameters"
"type": "String",
"desc": "s: return the value being set in Parameters"
}
],
"path": "PYTHON/nodes/GENERATORS/SIMULATIONS/TEXT/TEXT.py",
Expand Down
2 changes: 1 addition & 1 deletion blocks/COMPUTER_VISION/IMAGE_SMOOTHING/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"multiple": false,
"desc": "If this input node is connected, the filename will be taken from\nthe output of the connected node. To be used in conjunction with batch processing"
}
Expand Down
4 changes: 2 additions & 2 deletions blocks/CONTROL_FLOW/LOGICAL_OPERATORS/AND/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob|Boolean",
"type": "String|Boolean",
"multiple": false,
"desc": "The DataContainer to be visualized in text format"
}
Expand All @@ -174,7 +174,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"desc": "The DataContainer containing text data"
}
],
Expand Down
4 changes: 2 additions & 2 deletions blocks/CONTROL_FLOW/LOGICAL_OPERATORS/EXCLUSIVE_OR/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob|Boolean",
"type": "String|Boolean",
"multiple": false,
"desc": "The DataContainer to be visualized in text format"
}
Expand All @@ -124,7 +124,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"desc": "The DataContainer containing text data"
}
],
Expand Down
4 changes: 2 additions & 2 deletions blocks/CONTROL_FLOW/LOGICAL_OPERATORS/IMPLIES/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob|Boolean",
"type": "String|Boolean",
"multiple": false,
"desc": "The DataContainer to be visualized in text format"
}
Expand All @@ -124,7 +124,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"desc": "The DataContainer containing text data"
}
],
Expand Down
4 changes: 2 additions & 2 deletions blocks/CONTROL_FLOW/LOGICAL_OPERATORS/NOT/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob|Boolean",
"type": "String|Boolean",
"multiple": false,
"desc": "The DataContainer to be visualized in text format"
}
Expand All @@ -80,7 +80,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"desc": "The DataContainer containing text data"
}
],
Expand Down
4 changes: 2 additions & 2 deletions blocks/CONTROL_FLOW/LOGICAL_OPERATORS/NOT_AND/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob|Boolean",
"type": "String|Boolean",
"multiple": false,
"desc": "The DataContainer to be visualized in text format"
}
Expand All @@ -80,7 +80,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"desc": "The DataContainer containing text data"
}
],
Expand Down
4 changes: 2 additions & 2 deletions blocks/CONTROL_FLOW/LOGICAL_OPERATORS/NOT_OR/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob|Boolean",
"type": "String|Boolean",
"multiple": false,
"desc": "The DataContainer to be visualized in text format"
}
Expand All @@ -80,7 +80,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"desc": "The DataContainer containing text data"
}
],
Expand Down
4 changes: 2 additions & 2 deletions blocks/CONTROL_FLOW/LOGICAL_OPERATORS/OR/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob|Boolean",
"type": "String|Boolean",
"multiple": false,
"desc": "The DataContainer to be visualized in text format"
}
Expand All @@ -80,7 +80,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"desc": "The DataContainer containing text data"
}
],
Expand Down
6 changes: 3 additions & 3 deletions blocks/CONTROL_FLOW/LOOPS/APPEND/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,8 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"desc": "text_blob: return the value being set in Parameters"
"type": "String",
"desc": "s: return the value being set in Parameters"
}
],
"path": "PYTHON/nodes/GENERATORS/SIMULATIONS/TEXT/TEXT.py",
Expand Down Expand Up @@ -495,7 +495,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"multiple": false,
"desc": "the DataContainer to be visualized in text format"
}
Expand Down
6 changes: 3 additions & 3 deletions blocks/CONTROL_FLOW/LOOP_TOOLS/BREAK/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,8 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"desc": "text_blob: return the value being set in Parameters"
"type": "String",
"desc": "s: return the value being set in Parameters"
}
],
"path": "PYTHON/nodes/GENERATORS/SIMULATIONS/TEXT/TEXT.py",
Expand Down Expand Up @@ -627,7 +627,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"multiple": false,
"desc": "the DataContainer to be visualized in text format"
}
Expand Down
6 changes: 3 additions & 3 deletions blocks/CONTROL_FLOW/LOOP_TOOLS/LOOP_INDEX/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"type": "String",
"multiple": false,
"desc": "the DataContainer to be visualized in text format"
}
Expand Down Expand Up @@ -253,8 +253,8 @@
{
"name": "default",
"id": "default",
"type": "TextBlob",
"desc": "text_blob: return the value being set in Parameters"
"type": "String",
"desc": "s: return the value being set in Parameters"
}
],
"path": "PYTHON/nodes/GENERATORS/SIMULATIONS/TEXT/TEXT.py",
Expand Down
58 changes: 58 additions & 0 deletions blocks/DATA/EXPORT/EXPORT_CSV/EXPORT_CSV.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import pandas as pd
import os
from flojoy import (
DataFrame,
OrderedPair,
OrderedTriple,
Matrix,
flojoy,
DataContainer,
Directory,
)
from typing import Optional


@flojoy
def EXPORT_CSV(
dc: OrderedPair | OrderedTriple | DataFrame | Matrix,
dir: Directory,
filename: str = "exported.csv",
) -> Optional[DataContainer]:
"""Export a DataContainer into CSV format.
Parameters
----------
dc : OrderedPair|OrderedTriple|DataFrame
The DataContainer to export.
dir : Directory
The directory to export to.
filename : str
The name of the file to output.
Returns
-------
None
"""

if dir is None:
raise ValueError("Please select a directory to export the data to")

path = os.path.join(dir.unwrap(), filename)

match dc:
case OrderedPair() | OrderedTriple():
df = pd.DataFrame(dc)
df = df.drop(columns=["type", "extra"])
df.to_csv(path, index=False)
case DataFrame():
df = dc.m
df.to_csv(path, index=False)
case Matrix():
df = pd.DataFrame(dc.m)
df.to_csv(path, index=False, header=False)
case _:
raise ValueError(
f"Invalid DataContainer type: {dc.type} cannot be exported as CSV."
)

return None
Loading

0 comments on commit b4fcfe2

Please sign in to comment.