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

Support for Argo backend #19

Merged
merged 60 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
47eda1c
add: subparser for argoize
Nilabhra Nov 10, 2022
828e6d5
add: Nikhil's changes.
Nilabhra Nov 10, 2022
5c72277
feat: generating workflow name using output file name.
Nilabhra Nov 10, 2022
c394308
feat: function to create Argo template from node.
Nilabhra Nov 10, 2022
09f1c1c
chore: added docstring.
Nilabhra Nov 10, 2022
e42223c
chore: added comments.
Nilabhra Nov 10, 2022
35cb1be
feat: setting the env vars before generation of the argo yaml.
Nilabhra Nov 10, 2022
0b35916
feat: function to generate NFS volume specs for K8s.
Nilabhra Nov 10, 2022
c1ff95a
feat: added support for mounting NFS volumes.
Nilabhra Nov 10, 2022
d579f24
fix: using absolute path for the NFS mount paths.
Nilabhra Nov 10, 2022
64396a3
fix: typo.
Nilabhra Nov 10, 2022
1a7c0a9
feat: function for generating Argo templates for PIRlib Graph objects.
Nilabhra Nov 10, 2022
b901d3b
chore: added comments.
Nilabhra Nov 10, 2022
6052ae4
feat: enabled creation of DAG tasks.
Nilabhra Nov 10, 2022
fcc6768
chore: added Argo specific refactoring.
Nilabhra Nov 10, 2022
6316c87
chore: refactored argo task names.
Nilabhra Nov 10, 2022
8a9b5fd
fix: files cannot be mounted as volumes in Argo/K8s.
Nilabhra Nov 10, 2022
95fd3dd
chore: removed redundant module.
Nilabhra Nov 10, 2022
d339da2
chore: debugging code.
Nilabhra Nov 10, 2022
1bc1cea
chore: optimized docker image generation.
Nilabhra Nov 10, 2022
99912ef
add: dockerignore file to prevent copying of unnecessary files.
Nilabhra Nov 10, 2022
d552227
fix: missing volume mount.
Nilabhra Nov 10, 2022
a1c26c9
chore: reverted to original formatting.
Nilabhra Nov 11, 2022
46b3ca1
chore: removed spurious code.
Nilabhra Nov 11, 2022
ee19634
chore: increased black linelength to 100.
Nilabhra Nov 11, 2022
31c542a
Multistep pipeline support for Argo (#1)
Nilabhra Nov 14, 2022
2a60ba2
fix: type annotation.
Nilabhra Nov 16, 2022
49d1000
add: WIP files for one step execution of the wiki_parse pipeline.
Nilabhra Nov 16, 2022
01d33ff
fix: type annotation.
Nilabhra Nov 17, 2022
557d82b
add: WIP files for one step execution of the wiki_parse pipeline.
Nilabhra Nov 16, 2022
332f345
feat: wiki_parse example running as a single step.
Nilabhra Nov 18, 2022
cd51aab
fix: merge conflicts.
Nilabhra Nov 18, 2022
5045d4d
feat: PIRlib pipeline for parsing the sample Wikipedia data.
Nilabhra Nov 22, 2022
8995742
chore: renamed input directory.
Nilabhra Nov 22, 2022
2b8c8f6
add: input files.
Nilabhra Nov 22, 2022
d695521
add: shell file to download the full dbpedia dump.
Nilabhra Nov 22, 2022
9ad7382
add: scripts to run the PIRlib pipeline on the entire dbpedia dump.
Nilabhra Nov 22, 2022
c9fce68
chore: code cleanup.
Nilabhra Nov 22, 2022
ead051c
chore: removed unneeded imports.
Nilabhra Nov 22, 2022
367330a
feat: enabled parallel downloading of Wikipedia dumps.
Nilabhra Nov 23, 2022
355d6c1
add: readme containing usage instructions.
Nilabhra Nov 23, 2022
4e64fa4
Merge pull request #2 from Nilabhra/forte-wiki-parser
Nilabhra Nov 23, 2022
f082adb
Revert "Forte `wiki_parser`"
Nilabhra Nov 23, 2022
7fa241f
Merge pull request #3 from Nilabhra/revert-2-forte-wiki-parser
Nilabhra Nov 23, 2022
66dea30
Merge pull request #4 from Nilabhra/forte
Nilabhra Nov 24, 2022
ce78767
Revert "add: `wiki_parser` example from Forte"
Nilabhra Nov 24, 2022
793c048
Merge pull request #5 from Nilabhra/revert-4-forte
Nilabhra Nov 24, 2022
f584c95
feat: raising exception if required env vars are not defined.
Nilabhra Nov 29, 2022
6dbb27a
chore: refactored inp_name to inp_id.
Nilabhra Nov 29, 2022
2f00467
chore: reformatted shell command.
Nilabhra Nov 29, 2022
333b4d2
chore: reverted to inclusion of setting PYTHONPATH in the image.
Nilabhra Dec 5, 2022
c17156a
feat: prepending env of python to .
Nilabhra Dec 5, 2022
1ad74fe
feat: changed base image to continuumio/miniconda3.
Nilabhra Dec 5, 2022
535fa13
add: generated YAML files.
Nilabhra Dec 5, 2022
c4510c8
chore: incoporated PR feedback.
Nilabhra Dec 5, 2022
d23ca89
fix: conflicts.
Nilabhra Dec 5, 2022
2d65765
add: Usage instructions.
Nilabhra Dec 5, 2022
679bbf1
Merge branch 'argo-multistep'
Nilabhra Dec 5, 2022
bc9d923
chore: added Argo example to the main README.rst.
Nilabhra Dec 7, 2022
99386f6
chore: updated documentation.
Nilabhra Dec 7, 2022
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
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!example/yaml
!example/*py
!bin
!pirlib
35 changes: 17 additions & 18 deletions example/example.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import pandas
import tempfile
import yaml
from dataclasses import asdict
from typing import Tuple, TypedDict

import pandas
import yaml

from pirlib.frameworks.adaptdl import AdaptDL
from pirlib.iotypes import DirectoryPath, FilePath
from pirlib.task import task
from pirlib.pipeline import pipeline
from pirlib.task import task


@task
Expand Down Expand Up @@ -47,15 +48,14 @@ def evaluate(kwargs: EvaluateInput) -> pandas.DataFrame:


@task
def translate(args: Tuple[FilePath, DirectoryPath]) -> DirectoryPath:
model, sentences = args
def translate(args: Tuple[DirectoryPath, DirectoryPath]) -> DirectoryPath:
model_dir, sentences = args
task_ctx = task.context()
with open(model) as f, open(sentences / "file.txt") as g:
with open(model_dir / "translate_model.txt") as f, open(sentences / "file.txt") as g:
print(
"translate({}, {}, config={})".format(
f.read().strip(),
g.read().strip(),
task_ctx.config)
f.read().strip(), g.read().strip(), task_ctx.config
)
)
outdir = task_ctx.output
with open(outdir / "file.txt", "w") as f:
Expand All @@ -74,19 +74,18 @@ def sentiment(model: FilePath, sentences: DirectoryPath) -> DirectoryPath:


@pipeline
def infer_pipeline(translate_model: FilePath,
sentiment_model: FilePath,
sentences: DirectoryPath) -> DirectoryPath:
def infer_pipeline(
translate_model: DirectoryPath, sentiment_model: FilePath, sentences: DirectoryPath
) -> DirectoryPath:
translate_1 = translate.instance("translate_1")
translate_1.config["key"] = "value"
return sentiment(sentiment_model, translate_1((translate_model, sentences)))


@pipeline
def train_pipeline(
train_dataset: DirectoryPath,
translate_model: FilePath,
sentences: DirectoryPath) -> Tuple[FilePath, pandas.DataFrame]:
train_dataset: DirectoryPath, translate_model: FilePath, sentences: DirectoryPath
) -> Tuple[FilePath, pandas.DataFrame]:
sentiment_model = train(clean(train_dataset))
sentiment = infer_pipeline(translate_model, sentiment_model, sentences)
eval_input = {"test_dataset": sentences, "predictions": sentiment}
Expand All @@ -107,9 +106,9 @@ def train_pipeline(
with open(f"{dir_3.name}/file.txt", "w") as f:
f.write("sentences")
# Test calling end-to-end pipeline.
model_path, metrics = train_pipeline(DirectoryPath(dir_1.name),
FilePath(file_2.name),
DirectoryPath(dir_3.name))
model_path, metrics = train_pipeline(
DirectoryPath(dir_1.name), FilePath(file_2.name), DirectoryPath(dir_3.name)
)
with open(model_path) as f:
print("pipeline model: {}".format(f.read().strip()))
print("pipeline metrics: {}".format(metrics.to_records()))
Expand Down
25 changes: 25 additions & 0 deletions example/run_argo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
EXAMPLEDIR=$(dirname $0)
ROOTDIR=$EXAMPLEDIR/..

### Module 1: Docker_Packaging
python $ROOTDIR/bin/pircli dockerize \
--auto $ROOTDIR \
Copy link
Contributor

@zhanyuanucb zhanyuanucb Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, —auto $ROOTDIR is a bit confusing.
May be something like this will be better?

$ROOTDIR \
--auto

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

--pipeline example.example:train_pipeline \
--output $EXAMPLEDIR/package_argo.yml \
--flatten

# Convert EXAMPLEDIR to absolute path since docker can't bind-mount relative paths.
EXAMPLEDIR=$([[ $EXAMPLEDIR = /* ]] && echo "$EXAMPLEDIR" || echo "$PWD/${EXAMPLEDIR#./}")

### Module 2: Argoize_Module
INPUT_train_dataset=$EXAMPLEDIR/inputs/train_dataset \
INPUT_translate_model=$EXAMPLEDIR/inputs/ \
INPUT_sentences=$EXAMPLEDIR/inputs/sentences \
OUTPUT=$EXAMPLEDIR/outputs \
NFS_SERVER=k8s-master.cm.cluster \
python $ROOTDIR/bin/pircli generate $EXAMPLEDIR/package_argo.yml \
--target pirlib.backends.argo_batch:ArgoBatchBackend \
--output $EXAMPLEDIR/argo-train.yml

# Run the Argo workflow
argo submit -n argo --watch $EXAMPLEDIR/argo-train.yml
6 changes: 3 additions & 3 deletions example/run_docker.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
EXAMPLEDIR=$(dirname $0)
ROOTDIR=$EXAMPLEDIR/..

PYTHONPATH=$ROOTDIR $ROOTDIR/bin/pircli dockerize --auto $ROOTDIR \
python $ROOTDIR/bin/pircli dockerize --auto $ROOTDIR \
--pipeline example.example:train_pipeline \
--output $EXAMPLEDIR/package_docker.yml \
--flatten

PYTHONPATH=$ROOTDIR $ROOTDIR/bin/pircli generate $EXAMPLEDIR/package_docker.yml \
python $ROOTDIR/bin/pircli generate $EXAMPLEDIR/package_docker.yml \
--target pirlib.backends.docker_batch:DockerBatchBackend \
--output $EXAMPLEDIR/docker-compose.yml

# Convert EXAMPLEDIR to absolute path since docker can't bind-mount relative paths.
EXAMPLEDIR=$([[ $EXAMPLEDIR = /* ]] && echo "$EXAMPLEDIR" || echo "$PWD/${EXAMPLEDIR#./}")

INPUT_train_dataset=$EXAMPLEDIR/inputs/train_dataset \
INPUT_translate_model=$EXAMPLEDIR/inputs/translate_model.txt \
INPUT_translate_model=$EXAMPLEDIR/inputs \
INPUT_sentences=$EXAMPLEDIR/inputs/sentences \
OUTPUT=$EXAMPLEDIR/outputs \
docker-compose -f $EXAMPLEDIR/docker-compose.yml up --force-recreate -V
Expand Down
Loading