Skip to content

Commit a34a293

Browse files
📌 ISSUE-#35: Updated
1 parent f3378eb commit a34a293

File tree

6 files changed

+132
-5
lines changed

6 files changed

+132
-5
lines changed

‎examples/cli.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,19 @@
55
from dotflow import action
66

77

8-
def callback(*args, **kwargs):
9-
print(args, **kwargs)
10-
11-
128
@action
139
def simple_step():
1410
return "ok"
1511

1612

13+
def main():
14+
"""Output
15+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 56a908c5-c9f2-4ebf-a00a-895e49bd189b - 0 - Not started
16+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 56a908c5-c9f2-4ebf-a00a-895e49bd189b - 0 - In progress
17+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 56a908c5-c9f2-4ebf-a00a-895e49bd189b - 0 - Completed
18+
"""
19+
system("dotflow start --step examples.cli.simple_step")
20+
21+
1722
if __name__ == "__main__":
18-
system("dotflow task start --step examples.cli.simple_step")
23+
main()
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
3+
from os import system
4+
5+
from dotflow import action
6+
7+
8+
def callback(*args, **kwargs):
9+
print(args, kwargs)
10+
11+
12+
@action
13+
def simple_step():
14+
return "ok"
15+
16+
17+
def main():
18+
"""Output
19+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 56a908c5-c9f2-4ebf-a00a-895e49bd189b - 0 - Not started
20+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 56a908c5-c9f2-4ebf-a00a-895e49bd189b - 0 - In progress
21+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 56a908c5-c9f2-4ebf-a00a-895e49bd189b - 0 - Completed
22+
"""
23+
system("dotflow start --step examples.cli_with_callback.simple_step --callback examples.cli_with_callback.callback")
24+
25+
26+
if __name__ == "__main__":
27+
main()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
3+
from os import system
4+
5+
from dotflow import action
6+
7+
8+
@action
9+
def simple_step():
10+
return {"foo": "bar"}
11+
12+
13+
def main():
14+
"""
15+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 5ace2ca5-3d88-4119-a064-a9ae048826e9 - 0 - Initial Context -> abc
16+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 5ace2ca5-3d88-4119-a064-a9ae048826e9 - 0 - Not started
17+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 5ace2ca5-3d88-4119-a064-a9ae048826e9 - 0 - In progress
18+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 5ace2ca5-3d88-4119-a064-a9ae048826e9 - 0 - Completed
19+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 5ace2ca5-3d88-4119-a064-a9ae048826e9 - 0 - Current Context -> {'foo': 'bar'}
20+
"""
21+
system("dotflow start --step examples.cli_with_initial_context.simple_step --initial-context abc --output")
22+
23+
24+
if __name__ == "__main__":
25+
main()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
3+
from os import system
4+
5+
from dotflow import action
6+
7+
8+
@action
9+
def simple_step():
10+
return {"foo": "bar"}
11+
12+
13+
def main():
14+
"""
15+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 5ace2ca5-3d88-4119-a064-a9ae048826e9 - 0 - Initial Context -> None
16+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 5ace2ca5-3d88-4119-a064-a9ae048826e9 - 0 - Not started
17+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 5ace2ca5-3d88-4119-a064-a9ae048826e9 - 0 - In progress
18+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 5ace2ca5-3d88-4119-a064-a9ae048826e9 - 0 - Completed
19+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 5ace2ca5-3d88-4119-a064-a9ae048826e9 - 0 - Current Context -> {'foo': 'bar'}
20+
"""
21+
system("dotflow start --step examples.cli_with_output.simple_step --output")
22+
23+
24+
if __name__ == "__main__":
25+
main()

‎examples/cli_with_path.py‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
3+
from os import system
4+
5+
from dotflow import action
6+
7+
8+
@action
9+
def simple_step():
10+
return "ok"
11+
12+
13+
def main():
14+
"""Output
15+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 56a908c5-c9f2-4ebf-a00a-895e49bd189b - 0 - Not started
16+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 56a908c5-c9f2-4ebf-a00a-895e49bd189b - 0 - In progress
17+
0000-00-00 00:00:00,000 - INFO [dotflow]: ID 56a908c5-c9f2-4ebf-a00a-895e49bd189b - 0 - Completed
18+
"""
19+
system("dotflow start --step examples.cli_with_path.simple_step --path my_folder")
20+
system("dotflow start --step examples.cli_with_path.simple_step --path /home/your_user/log")
21+
system("dotflow start --step examples.cli_with_path.simple_step --path .")
22+
23+
24+
if __name__ == "__main__":
25+
main()

‎tests/test_integration.py‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
import unittest
44

5+
from examples.cli_with_callback import main as cli_with_callback
6+
from examples.cli_with_initial_context import main as cli_with_initial_context
7+
from examples.cli_with_output import main as cli_with_output
8+
from examples.cli_with_path import main as cli_with_path
9+
from examples.cli import main as cli
510
from examples.simple_class_workflow import main as simple_class_workflow
611
from examples.simple_function_workflow_with_error import main as simple_function_workflow_with_error
712
from examples.simple_function_workflow import main as simple_function_workflow
@@ -23,6 +28,21 @@
2328

2429
class TestIntegration(unittest.TestCase):
2530

31+
def test_cli_with_callback(self):
32+
cli_with_callback()
33+
34+
def test_cli_with_initial_context(self):
35+
cli_with_initial_context()
36+
37+
def test_cli_with_output(self):
38+
cli_with_output()
39+
40+
def test_cli_with_path(self):
41+
cli_with_path()
42+
43+
def test_cli(self):
44+
cli()
45+
2646
def test_simple_class_workflow(self):
2747
simple_class_workflow()
2848

0 commit comments

Comments
 (0)