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

Replaced example folder with a simpler workflow #126

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This folder contains a simple example workflow.

You can start the workflow by running:
`sis manager config/workflow.main`

- `config/workflow.py` contains the workflow definition, start here reading the code and comments
- `recipe/` contains the modules which define the actual jobs
- - `tools.py` continue reading here
- - `splitter/__init__.py` read this file last
43 changes: 0 additions & 43 deletions example/config/__init__.py

This file was deleted.

23 changes: 0 additions & 23 deletions example/config/dump.py

This file was deleted.

49 changes: 49 additions & 0 deletions example/config/workflow.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# This imports all things typically used sisyphus
from sisyphus import *
from recipe import tools
from recipe import splitter


# Workflow example, it is possible to have multiple workflows in the same file. Since this function is named `main`
# you can call it by running sis manager config/workflow.main
async def main():
# Initialize input data, tags are optional. The have no influence on the workflow,
# but make it easier to track which input influenced a job
input_data = tk.Path('input/lorem_upsum.txt', tags={'lorem_upsum'})

# Create new lines after . and remove empty spaces at the beginning and end of each line
sentences = tools.Pipeline(input_data, ["sed 's:\\.:\\n:g'", "sed 's:^ *::;s: *$::'"]).out

# Count lines, lines is a Variable meaning once it's computed its value can be accessed using .get()
# or by converting it into a string
num_lines = tools.WordCount(sentences).lines

# You can run computations on these variables even though they are not computed yet.
# The requested computation is stored in a wrapper object and only resolved when .get() is called
# or the object is converted into a string. An exception is raised if you call get() on an unfinished Variable
# which doesn't have a backup value.
middle = num_lines // 2
first_half = tools.Head(sentences, middle).out

# Tell Sisyphus that this output is needed and should be linked inside the output directory
Copy link
Contributor

Choose a reason for hiding this comment

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

move the comment up three lines before the first use of tk.register_output

tk.register_output('first_half', first_half)
tk.register_output('sentences', sentences)

# Split each paragraph into a new line and again register output
paragraphs_job = splitter.ParagraphSplitter(sentences)

# paragraphs_job.outputs() is a coroutine, the `await` keyword will make sure that the
# workflow will be stopped at this point and only continue once the paragraphs_job is finished
paragraphs = await paragraphs_job.outputs()
wc_per_paragraph = [tools.WordCount(paragraph) for paragraph in paragraphs]

for i, wc in enumerate(wc_per_paragraph):
# You can also register variables as output:
tk.register_output('paragraph.%02i.words' % i, wc.words)

# All jobs inside the wc_per_paragraph list will be computed after this line
await tk.async_run(wc_per_paragraph)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this can be part of the simple example, but what do you do if you have multiple experiments and you do not want to block "later" experiements that are independent of this run?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You'll have to put everything that can run in parallel into its own coroutine and await all of them at the end like this:
await tk.async_gather(coroutine1, coroutine2, coroutine3, ...)


# We can now get the final value of all variables
max_word_per_paragraph = max(wc.words.get() for wc in wc_per_paragraph)
print(f"The largest paragraph has {max_word_per_paragraph} words")
5 changes: 0 additions & 5 deletions example/data/5lines.txt

This file was deleted.

21 changes: 21 additions & 0 deletions example/input/lorem_upsum.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.

At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.

Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus.

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo
Empty file removed example/recipe/__init__.py
Empty file.
19 changes: 0 additions & 19 deletions example/recipe/direct_load.py

This file was deleted.

64 changes: 0 additions & 64 deletions example/recipe/math.py

This file was deleted.

101 changes: 0 additions & 101 deletions example/recipe/parallel/__init__.py

This file was deleted.

Loading