Skip to content

Commit

Permalink
metadata changes
Browse files Browse the repository at this point in the history
  • Loading branch information
luiztauffer committed Nov 14, 2023
1 parent df5087a commit 2572fd0
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 65 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[![codecov](https://codecov.io/gh/Tauffer-Consulting/default_domino_pieces/graph/badge.svg?token=DLCDR2S3B6)](https://codecov.io/gh/Tauffer-Consulting/default_domino_pieces)

# Default Domino Pieces
Default Domino Pieces that comes pre-installed:
Default Domino Pieces that comes pre-installed in every Domino workspace:

- **SimpleLogPiece** - A simple logging Piece.
- **SleepPiece** - A Piece that executes a Python sleep function for a user-defined duration.
- **GetDateTimePiece** - A Piece that returns the current date and time.
- **CustomPythonPiece** - A Piece that executes a user-defined Python function.
- **GetDateTimePiece** - A Piece that returns the current date and time.
- **GetItemFromArrayPiece** - A Piece that returns an item from an array.
- **LogPiece** - A simple logging Piece.
- **LoremIpsumPiece** - A Piece that returns a random Lorem Ipsum text.
- **PageScrapperPiece** - A Piece that scrapes text from a web page, given a URL and a list of HTML tags.
- **SleepPiece** - A Piece that sleeps for a given number of seconds.
- **ToStringPiece** - A Piece that converts any input to string.
8 changes: 4 additions & 4 deletions pieces/CustomPythonPiece/metadata.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "CustomPythonPiece",
"description": "Run your custom Python code.",
"description": "Executes user-defined Python code.",
"dependency": {
"requirements_file": "requirements_0.txt"
},
"tags": [
"python",
"default"
"default",
"python"
],
"style": {
"node_label": "Custom Python Piece",
"node_label": "Custom Python",
"node_style": {
"backgroundColor": "#b3cde8"
},
Expand Down
6 changes: 3 additions & 3 deletions pieces/GetDateTimePiece/metadata.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "GetDateTimePiece",
"description": "A Piece that gets current system date and time.",
"description": "A Piece that gets system's current date and time.",
"dependency": {
"requirements_file": "requirements_0.txt"
},
"tags": [
"datetime",
"default"
"default",
"datetime"
],
"style": {
"node_label": "Get Datetime",
Expand Down
7 changes: 4 additions & 3 deletions pieces/GetItemFromArrayPiece/metadata.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "GetItemFromArrayPiece",
"description": "Get one item from an array",
"description": "Get one item from an input array.",
"dependency": {
"requirements_file": "requirements_0.txt"
},
"tags": [
"default"
"default",
"array"
],
"style": {
"node_label": "Get Item From Array Piece",
"node_label": "Get Item From Array",
"node_style": {
"backgroundColor": "#b3cde8"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "SimpleLogPiece",
"description": "A Piece that simply logs its input",
"name": "LogPiece",
"description": "A Piece that logs its inputs.",
"dependency": {
"requirements_file": "requirements_0.txt"
},
"tags": [
"log",
"default"
"default",
"log"
],
"style": {
"node_label": "Simple Log Piece",
"node_label": "Log",
"node_style": {
"backgroundColor": "#b3cde8"
},
Expand Down
35 changes: 16 additions & 19 deletions pieces/SimpleLogPiece/models.py → pieces/LogPiece/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class InputEnum(str, Enum):

class InputModel(BaseModel):
"""
SimpleLogPiece Input Model
LogPiece Input Model
"""
input_str: str = Field(
default="default value",
Expand Down Expand Up @@ -61,43 +61,40 @@ class InputModel(BaseModel):

class OutputModel(BaseModel):
"""
SimpleLogPiece Output Model
LogPiece Output Model
"""
message: str = Field(
default="",
description="Output message to log."
output_log: str = Field(
description='All values logged.'
)
output_msg: str = Field(
description='Value that was logged.'
)

# Outputs types
output_str: Optional[str] = Field(
description='Output string to be logged.'
description='Output string logged.'
)
output_int: Optional[int] = Field(
description='Output integer to be logged.'
description='Output integer logged.'
)
output_float: Optional[float] = Field(
description='Output float to be logged.'
description='Output float logged.'
)
output_bool: Optional[bool] = Field(
description='Output boolean to be logged.'
description='Output boolean logged.'
)
output_enum: Optional[str] = Field(
description='Output enum logged.'
)
output_date: date = Field(
description='Output date to be logged.'
description='Output date logged.'
)
output_time: time = Field(
description='Output time to be logged.',
description='Output time logged.',
)
output_datetime: datetime = Field(
description='Output datetime to be logged.'
description='Output datetime logged.'
)
output_array: List[str] = Field(
description='Output array to be logged.'
description='Output array logged.'
)
output_code: str = Field(
description='Input code to be logged.',
description='Output code logged.',
json_schema_extra={
'widget': "codeeditor",
}
Expand Down
14 changes: 5 additions & 9 deletions pieces/SimpleLogPiece/piece.py → pieces/LogPiece/piece.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
from pathlib import Path


class SimpleLogPiece(BasePiece):
class LogPiece(BasePiece):

def piece_function(self, input_data: InputModel):
# Log inputs
msg = f"""
#############################################################################\n
Logged inputs:\n
msg = f"""## Log Piece: \n\n
Input string: {input_data.input_str}\n
Input integer: {input_data.input_int}\n
Input float: {input_data.input_float}\n
Expand All @@ -20,7 +18,6 @@ def piece_function(self, input_data: InputModel):
Input time: {input_data.input_time}\n
Input datetime: {input_data.input_datetime}\n
Input code: {input_data.input_code}\n
#############################################################################\n
"""
self.logger.info(msg)

Expand All @@ -38,16 +35,15 @@ def piece_function(self, input_data: InputModel):

# Return output
return OutputModel(
message="Task successfully completed!",
output_msg=msg,
output_log=msg,
output_str=input_data.input_str,
output_int=input_data.input_int,
output_float=input_data.input_float,
output_bool=input_data.input_bool,
output_array=input_data.input_array,
output_enum=input_data.input_enum,
output_array=input_data.input_array,
output_date=input_data.input_date,
output_time=input_data.input_time,
output_datetime=input_data.input_datetime,
output_code=input_data.input_code
)
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from domino.testing import piece_dry_run


def test_simple_log_piece():
def test_log_piece():
input_data = dict(
input_str='test string',
input_int=10,
Expand All @@ -17,17 +17,16 @@ def test_simple_log_piece():

piece_output = piece_dry_run(
repository_folder_path=".",
piece_name="SimpleLogPiece",
piece_name="LogPiece",
input_data=input_data
)

mock_output = dict(
message="Task successfully completed!",
output_msg='test',
output_str=input_data.get("input_str"),
output_int=input_data.get("input_int"),
output_float=input_data.get("input_float"),
output_bool=input_data.get("input_bool"),
output_enum=input_data.get("input_enum"),
output_array=input_data.get("input_array"),
output_date=input_data.get("input_date"),
output_time=input_data.get("input_time"),
Expand All @@ -36,6 +35,7 @@ def test_simple_log_piece():
)

for key, value in piece_output.items():
if key in ['message', 'output_msg']:
if key in ['output_log']:
assert isinstance(value, str)
continue
assert value == mock_output[key]
assert value == mock_output[key]
3 changes: 2 additions & 1 deletion pieces/LoremIpsumGeneratorPiece/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"requirements_file": "requirements_0.txt"
},
"tags": [
"Default"
"default",
"text"
],
"style": {
"node_label": "Lorem Ipsum Generator",
Expand Down
5 changes: 3 additions & 2 deletions pieces/PageScrapperPiece/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"requirements_file": "requirements_0.txt"
},
"tags": [
"Default"
"default",
"scrapper"
],
"style": {
"node_label": "Page Scrapper Piece",
"node_label": "Page Scrapper",
"node_style": {
"backgroundColor": "#b3cde8"
},
Expand Down
6 changes: 3 additions & 3 deletions pieces/SaveImagePiece/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"requirements_file": "requirements_0.txt"
},
"tags": [
"image",
"default"
"default",
"image"
],
"style": {
"node_label": "Save Image Piece",
"node_label": "Save Image",
"node_style": {
"backgroundColor": "#b3cde8"
},
Expand Down
8 changes: 4 additions & 4 deletions pieces/SleepPiece/metadata.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "SleepPiece",
"description": "A Piece that executes a Python sleep function for a user-defined duration",
"description": "A Piece that sleeps for a given number of seconds.",
"dependency": {
"requirements_file": "requirements_0.txt"
},
"tags": [
"Sleep",
"Default"
"default",
"sleep"
],
"style": {
"node_label": "Sleep Piece",
"node_label": "Sleep",
"node_style": {
"backgroundColor": "#b3cde8"
},
Expand Down
1 change: 1 addition & 0 deletions pieces/SleepPiece/test_sleep_piece.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from domino.testing import piece_dry_run
from datetime import datetime


def test_sleep_piece():
sleep_time = 1
input_data = dict(
Expand Down
5 changes: 3 additions & 2 deletions pieces/ToStringPiece/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"requirements_file": "requirements_0.txt"
},
"tags": [
"Default"
"default",
"string"
],
"style": {
"node_label": "To String Piece",
"node_label": "To String",
"node_style": {
"backgroundColor": "#b3cde8"
},
Expand Down

0 comments on commit 2572fd0

Please sign in to comment.