Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #22

Open
wants to merge 12 commits into
base: main
Choose a base branch
from
Open

Dev #22

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,796 changes: 945 additions & 851 deletions .domino/compiled_metadata.json

Large diffs are not rendered by default.

23 changes: 12 additions & 11 deletions .domino/dependencies_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@
"requirements_file": "requirements_0.txt"
},
"pieces": [
"SaveImagePiece",
"GetDateTimePiece",
"CustomPythonPiece",
"LogPiece",
"GetItemFromArrayPiece",
"ToyDatasetsPiece",
"SaveImagePiece",
"ImageFilterPiece",
"DataConversionPiece",
"YDataProfilingPiece",
"StringConditionChecksPiece",
"LoremIpsumGeneratorPiece",
"ToStringPiece",
"GetDateTimePiece",
"LogPiece",
"PageScrapperPiece",
"SleepPiece",
"HttpRequestPiece",
"StringOperationsPiece",
"ToyDatasetsPiece",
"ToStringPiece",
"LoremIpsumGeneratorPiece",
"GetItemFromArrayPiece",
"HttpRequestPiece"
"DataConversionPiece",
"YDataProfilingPiece",
"RenameTabularColumnsPiece"
],
"secrets": [],
"source_image": "ghcr.io/tauffer-consulting/default_domino_pieces:0.8.1-group0"
"source_image": "ghcr.io/tauffer-consulting/default_domino_pieces:development-group0"
}
}
11 changes: 8 additions & 3 deletions .github/workflows/tests-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@ jobs:
with:
python-version: "3.10"

- name: Pip install packages
# - name: Pip install packages
# run: |
# python -m pip install -U pip
# pip install --no-cache-dir domino-py[cli]
# TODO remove
- name: Pip install from branch
run: |
python -m pip install -U pip
pip install --no-cache-dir domino-py[cli]
pip install git+https://github.com/Tauffer-Consulting/domino@dev#egg=domino-py[cli]

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand All @@ -37,7 +42,7 @@ jobs:

- name: Run organize and build images
run: |
domino piece organize --build-images --source-url=https://github.com/${{github.repository}} --tag-overwrite=development
domino piece organize --build-images --source-url=https://github.com/${{github.repository}} --tag-overwrite=development --dev

- name: Install Tests Dependencies
run: pip install -r requirements-tests.txt
Expand Down
1 change: 0 additions & 1 deletion config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ REPOSITORY_NAME = "default_domino_pieces"
REPOSITORY_LABEL = "Default Pieces Repository"

VERSION = "0.8.1"

2 changes: 1 addition & 1 deletion pieces/CustomPythonPiece/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class InputModel(BaseModel):
}
)
script: str = Field(
default="""# Do not modify the function definition line
default="""# Do not modify the function name in definition line
def custom_function(kwarg_1, kwarg_2):
# Write your code here
print(f"First argument: {kwarg_1}")
Expand Down
4 changes: 2 additions & 2 deletions pieces/PageScrapperPiece/models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
from pydantic import BaseModel, Field
from typing import List
from typing import List, Optional


class ItemType(BaseModel):
tag: str = Field(
default="p",
description='HTML tag name.',
)
class_name: str = Field(
class_name: Optional[str] = Field(
default="",
description='HTML tag class name.',
)
Expand Down
16 changes: 16 additions & 0 deletions pieces/RenameTabularColumnsPiece/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "RenameTabularColumnsPiece",
"description": "A piece that receives an dataframe and a dictionary with the columns to rename and returns the dataframe with the columns renamed.",
"dependency": {
"requirements_file": "requirements_0.txt"
},
"tags": [
"default",
"pandas",
"dataframe"
],
"style": {
"node_label": "Rename Tabular Columns",
"icon_class_name": "icon-park-twotone:data-file"
}
}
35 changes: 35 additions & 0 deletions pieces/RenameTabularColumnsPiece/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from pydantic import BaseModel, Field
from typing import List

class ColumnsToRename(BaseModel):
"""
ColumnsToRename Model
"""
old_column_name: str = Field(
title='Old Column Name',
)
new_column_name: str = Field(
title='New Column Name',
)

class InputModel(BaseModel):
"""
GetDateTimePiece Input Model
"""
input_data: str = Field(
description='Input data.'
)

columns_to_rename: List[ColumnsToRename] = Field(
title='Columns to Rename',
description='List of columns to rename.'
)


class OutputModel(BaseModel):
"""
GetDateTimePiece Output Model
"""
output_data: str = Field(
description='Output data.'
)
32 changes: 32 additions & 0 deletions pieces/RenameTabularColumnsPiece/piece.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from domino.base_piece import BasePiece
from .models import InputModel, OutputModel
import pandas as pd
from pathlib import Path


class RenameTabularColumnsPiece(BasePiece):

def piece_function(self, input_data: InputModel):
"""
GetDateTimePiece piece function.
"""
input_data_file = input_data.input_data
if input_data_file.endswith('.csv'):
df = pd.read_csv(input_data_file)
elif input_data_file.endswith('.json'):
df = pd.read_json(input_data_file)
else:
raise ValueError("File format not supported. Please pass a CSV or JSON file.")

columns_to_rename = {}
for columns_data in input_data.columns_to_rename:
columns_to_rename[columns_data.old_column_name] = columns_data.new_column_name

df.rename(columns=columns_to_rename, inplace=True)

output_data_path = Path(self.results_path) / 'output_data.csv'
df.to_csv(output_data_path, index=False)

return OutputModel(output_data=str(output_data_path))


8 changes: 8 additions & 0 deletions pieces/RenameTabularColumnsPiece/test_rename_columns_piece.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from domino.testing import piece_dry_run




def test_rename_columns_piece():
...