Skip to content

Commit

Permalink
feat: setup basic plugin with example
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunc committed Feb 15, 2022
1 parent 9ff0e82 commit 67dd08d
Show file tree
Hide file tree
Showing 8 changed files with 165 additions and 138 deletions.
28 changes: 28 additions & 0 deletions bin/create-sample-project.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# create a test project under ./tmp which uses the kedro-dvc plugin as
# "editable" install.
#
set -e

name=$1
from_branch=${2:-sample-project-basic}

if [[ "$name" == "" ]] ; then
echo "usage: setup-sample-project.sh <name> [from-branch]"
exit 1
fi
echo "creating sample project $name from branch $from_branch"

mkdir -p tmp
cd tmp
mkdir $name
cd $name
git clone git@github.com:FactFiber/kedro-dvc.git -b $from_branch .
python3.8 -m venv env/$name
source env/$name/bin/activate
pip install --upgrade pip # ensure pip version >22
pip install -r src/requirements.txt
hash -r # ensure shell notes local version of kedro
kedro --help
# we should see kedro-dvc commands listed
echo "to use the sample project run "\""source env/$name"\"""
17 changes: 0 additions & 17 deletions kedrojson/plugin.py

This file was deleted.

181 changes: 89 additions & 92 deletions poetry.lock

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ packages = [{include = "kedro_dvc", from = "src"}]

[tool.poetry.dependencies]
dvc = "^2.9.3"
kedro = ">=0.17.6, <0.19"
numpy = "^1.22.2"
python = ">=3.8, <3.10"
kedro = {url = "https://github.com/kedro-org/kedro/archive/develop.zip"}
python = ">=3.8, <3.9"

[tool.poetry.dev-dependencies]
black = "21.12b0"
black = "21.12b0, <23"
flake8 = "^4.0.1"
isort = "^5.10.1"
mypy = "^0.931"
Expand All @@ -25,7 +25,14 @@ pytest-cov = "^3.0.0"

[build-system]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core>=1.0.0"]
requires = ["poetry-core @ git+https://github.com/python-poetry/poetry-core.git@master"]

[tool.poetry-exec-plugin.commands]
create-sample-project = "bin/create-sample-project.sh"

# NB poetry does not (yet?) support
[tool.poetry.plugins."kedro.project_commands"]
dvc = "kedro_dvc.plugin:dvc"

[tool.black]
exclude = '''
Expand Down
8 changes: 0 additions & 8 deletions setup.py

This file was deleted.

17 changes: 0 additions & 17 deletions src/kedro_dvc.py

This file was deleted.

18 changes: 18 additions & 0 deletions src/kedro_dvc/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
__version__ = "0.2.0"

import click
from kedro.framework.session import KedroSession


@click.group(name="JSON")
def commands():
"""Kedro plugin for printing the pipeline in JSON format"""
pass


@commands.command()
@click.pass_obj
def to_json(metadata):
"""Display the pipeline in JSON format"""
session = KedroSession.create(metadata.package_name)
context = session.load_context()
print(context.pipeline.to_json())
19 changes: 19 additions & 0 deletions src/kedro_dvc/plugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import click

# from kedro.framework.session import KedroSession


@click.group(name="dvc")
def dvc():
"""Kedro-DVC integration."""
pass


@dvc.command()
@click.pass_obj
def hello(metadata):
"""Display the pipeline in JSON format"""
# session = KedroSession.create(metadata.package_name)
# context = session.load_context()
# print(context.pipeline.to_json())
print("HELLO", metadata)

0 comments on commit 67dd08d

Please sign in to comment.