From 773f86fd019e64c412a9dcd897662f43eeecf63e Mon Sep 17 00:00:00 2001
From: szymekc <szymekc98@gmail.com>
Date: Mon, 2 Nov 2020 12:31:57 +0100
Subject: [PATCH 01/17] WIP lpmn completer

---
 lpmn_client/src/console.py   | 16 ++++++++++++++++
 lpmn_client/src/requester.py |  5 +++++
 lpmn_services.yaml           | 22 ++++++++++++++++++++++
 requirements.txt             |  3 ++-
 4 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 lpmn_services.yaml

diff --git a/lpmn_client/src/console.py b/lpmn_client/src/console.py
index 0b1108a..0b8c447 100644
--- a/lpmn_client/src/console.py
+++ b/lpmn_client/src/console.py
@@ -7,6 +7,8 @@ import os
 import readline
 import sys
 
+import yaml
+
 from lpmn_client.src.requester import Requester
 
 
@@ -40,6 +42,11 @@ class Console(cmd.Cmd, object):
         self.cmdqueue = []
         self.stdout = sys.stdout
         self.last_upload = []
+        with open("lpmn_services.yaml", 'r') as f:
+            try:
+                self.services = yaml.safe_load(f)
+            except yaml.YAMLError as exc:
+                print(exc)
         readline.set_completer_delims(" \t\n")
 
     def do_upload(self, args: str):
@@ -148,6 +155,11 @@ class Console(cmd.Cmd, object):
         """Autocomplete for download."""
         return self._complete_path(text)
 
+    def complete_lpmn(self, text, line, start, end):
+        """Autocomplete for lpmn."""
+        return self._complete_lpmn(text)
+
+
     def do_exit(self, s):
         """Exit the application."""
         print("\n")
@@ -182,6 +194,10 @@ class Console(cmd.Cmd, object):
         else:
             return gb.glob(path + "*")
 
+    def _complete_lpmn(self, text):
+        #TODO add pipeline filtering
+        return [x for x in self.services.keys() if x.startswith(text)]
+
     def _do_upload_string(self, string):
         return self._requester.upload_strings(string)
 
diff --git a/lpmn_client/src/requester.py b/lpmn_client/src/requester.py
index 3c5187d..3a5751d 100644
--- a/lpmn_client/src/requester.py
+++ b/lpmn_client/src/requester.py
@@ -214,3 +214,8 @@ class Requester(object):
             os.remove("progress.tmp")
         except FileNotFoundError:
             return
+
+    def _sync_lpmn_complete(self, url):
+        req = requests.get(url).content.decode("utf-8")
+        with open("lpmn_services.yaml", "wt") as f:
+            f.write(req)
diff --git a/lpmn_services.yaml b/lpmn_services.yaml
new file mode 100644
index 0000000..ab4bc63
--- /dev/null
+++ b/lpmn_services.yaml
@@ -0,0 +1,22 @@
+any2txt:
+  next:
+    - service1
+    - service2
+
+service1:
+  next:
+    - service3
+  params:
+    - param1
+    - param2
+    - param3
+
+service2:
+  next:
+    - service3
+  params:
+    - param1
+    - param2
+
+service3:
+  params: None
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
index 663bd1f..fda3075 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1 +1,2 @@
-requests
\ No newline at end of file
+requests
+pyyaml
\ No newline at end of file
-- 
GitLab


From eacf2c299f695c28313bf11a715ca5aeb0a5dbd8 Mon Sep 17 00:00:00 2001
From: szymekc <szymekc98@gmail.com>
Date: Fri, 6 Nov 2020 09:49:18 +0100
Subject: [PATCH 02/17] added lpmn completion with next service

---
 lpmn_client/src/console.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/lpmn_client/src/console.py b/lpmn_client/src/console.py
index 0b8c447..6c99e61 100644
--- a/lpmn_client/src/console.py
+++ b/lpmn_client/src/console.py
@@ -17,6 +17,7 @@ class Console(cmd.Cmd, object):
 
     def __init__(self, email=None):
         """Initializes the Console class instance."""
+        super().__init__()
         self.intro = (
             "Welcome to the LPMN console. Type help or ? to list commands.\n"
         )
@@ -47,7 +48,7 @@ class Console(cmd.Cmd, object):
                 self.services = yaml.safe_load(f)
             except yaml.YAMLError as exc:
                 print(exc)
-        readline.set_completer_delims(" \t\n")
+        readline.set_completer_delims(" |\t\n")
 
     def do_upload(self, args: str):
         """Uploads a file.
@@ -157,8 +158,11 @@ class Console(cmd.Cmd, object):
 
     def complete_lpmn(self, text, line, start, end):
         """Autocomplete for lpmn."""
-        return self._complete_lpmn(text)
-
+        commands = line.replace("lpmn ", "").split("|")
+        try:
+            return [x for x in self.services.keys() if x.startswith(text) and x in self.services[commands[-2]]["next"]]
+        except (KeyError, IndexError):
+            return [x for x in self.services.keys() if x.startswith(text)]
 
     def do_exit(self, s):
         """Exit the application."""
@@ -194,10 +198,6 @@ class Console(cmd.Cmd, object):
         else:
             return gb.glob(path + "*")
 
-    def _complete_lpmn(self, text):
-        #TODO add pipeline filtering
-        return [x for x in self.services.keys() if x.startswith(text)]
-
     def _do_upload_string(self, string):
         return self._requester.upload_strings(string)
 
-- 
GitLab


From 2d010625157d3a937969cd9b202ba25e4e73a1e8 Mon Sep 17 00:00:00 2001
From: szymekc <szymekc98@gmail.com>
Date: Fri, 6 Nov 2020 11:35:09 +0100
Subject: [PATCH 03/17] pep8

---
 lpmn_client/src/console.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lpmn_client/src/console.py b/lpmn_client/src/console.py
index 6c99e61..9964f43 100644
--- a/lpmn_client/src/console.py
+++ b/lpmn_client/src/console.py
@@ -43,7 +43,7 @@ class Console(cmd.Cmd, object):
         self.cmdqueue = []
         self.stdout = sys.stdout
         self.last_upload = []
-        with open("lpmn_services.yaml", 'r') as f:
+        with open("lpmn_services.yaml", "r") as f:
             try:
                 self.services = yaml.safe_load(f)
             except yaml.YAMLError as exc:
@@ -160,7 +160,12 @@ class Console(cmd.Cmd, object):
         """Autocomplete for lpmn."""
         commands = line.replace("lpmn ", "").split("|")
         try:
-            return [x for x in self.services.keys() if x.startswith(text) and x in self.services[commands[-2]]["next"]]
+            return [
+                x
+                for x in self.services.keys()
+                if x.startswith(text)
+                and x in self.services[commands[-2]]["next"]
+            ]
         except (KeyError, IndexError):
             return [x for x in self.services.keys() if x.startswith(text)]
 
-- 
GitLab


From 840e085d6d250097b314db9ed6d205bdb15a1d93 Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 09:55:08 +0000
Subject: [PATCH 04/17] Update setup.py

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index fd45954..66aa6a4 100644
--- a/setup.py
+++ b/setup.py
@@ -15,6 +15,6 @@ setuptools.setup(
     python_requires=">=3.6",
     zip_safe=True,
     entry_points={"console_scripts": ["lpmn_client=lpmn_client.__main__:main"]},
-    install_requires=["requests"],
+    install_requires=["requests", "pyyaml"],
     package_data={"lpmn_client": ["config.ini"]},
 )
-- 
GitLab


From 5db821cee7f90980d8d962a036daed88d5812f21 Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 10:00:53 +0000
Subject: [PATCH 05/17] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 52c2502..ba8b932 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,6 +11,7 @@ stages:
 
 before_script:
   - pip install tox==2.9.1
+  - pip install -r requirements.txt
 
 pep8:
   stage: check_style
-- 
GitLab


From d53db614897bb837dad5b12f27351a3e9ac2a95c Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 10:04:10 +0000
Subject: [PATCH 06/17] Revert "Update .gitlab-ci.yml"

This reverts commit 5db821cee7f90980d8d962a036daed88d5812f21
---
 .gitlab-ci.yml | 1 -
 1 file changed, 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ba8b932..52c2502 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,7 +11,6 @@ stages:
 
 before_script:
   - pip install tox==2.9.1
-  - pip install -r requirements.txt
 
 pep8:
   stage: check_style
-- 
GitLab


From 21f47e70228cf26989bc8952fb18bd333205a173 Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 10:05:48 +0000
Subject: [PATCH 07/17] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 52c2502..67343e2 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,6 +10,7 @@ stages:
   - push_wheel
 
 before_script:
+  - apt-get install python3-dev
   - pip install tox==2.9.1
 
 pep8:
-- 
GitLab


From 75e247a0105f9617879651202b278a62c6926e1e Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 10:06:34 +0000
Subject: [PATCH 08/17] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 67343e2..51798b3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,7 +10,7 @@ stages:
   - push_wheel
 
 before_script:
-  - apt-get install python3-dev
+  - apt-get install -y python3-dev
   - pip install tox==2.9.1
 
 pep8:
-- 
GitLab


From d612b90e1d82828c33d6d1c78d0b31b5c9f9d4ee Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 10:07:17 +0000
Subject: [PATCH 09/17] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 51798b3..c36363b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -10,7 +10,7 @@ stages:
   - push_wheel
 
 before_script:
-  - apt-get install -y python3-dev
+  - apt-get update && apt-get install -y python3-dev
   - pip install tox==2.9.1
 
 pep8:
-- 
GitLab


From 81b5856ca0dfc66f623d65b59266441657b1ebeb Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 10:15:32 +0000
Subject: [PATCH 10/17] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c36363b..ae78802 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,6 +11,7 @@ stages:
 
 before_script:
   - apt-get update && apt-get install -y python3-dev
+  - pip install -r requirements.txt
   - pip install tox==2.9.1
 
 pep8:
-- 
GitLab


From 6657a2e0f2b0f85f83c85128d614fd07a1baf614 Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 10:20:21 +0000
Subject: [PATCH 11/17] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ae78802..0f8c122 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: clarinpl/python:3.6
+image: clarinpl/python:3.8
 
 cache:
   paths:
-- 
GitLab


From aed410b0cc9203b632795415331b40c43bd6194a Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 10:28:22 +0000
Subject: [PATCH 12/17] Update setup.py

---
 setup.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.py b/setup.py
index 66aa6a4..caff30a 100644
--- a/setup.py
+++ b/setup.py
@@ -12,7 +12,7 @@ setuptools.setup(
     long_description=long_description,
     long_description_content_type="text/markdown",
     packages=setuptools.find_packages(exclude="tests"),
-    python_requires=">=3.6",
+    python_requires=">=3.8",
     zip_safe=True,
     entry_points={"console_scripts": ["lpmn_client=lpmn_client.__main__:main"]},
     install_requires=["requests", "pyyaml"],
-- 
GitLab


From ae989b4bdd1cf002bf4f2a4ed9357101bc54d128 Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 10:32:59 +0000
Subject: [PATCH 13/17] Update tox.ini

---
 tox.ini | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tox.ini b/tox.ini
index fee2d44..8a47cb4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -6,6 +6,7 @@ skipsdist = True
 deps = 
     pytest
     requests
+    pyyaml
 commands = pytest
 
 [testenv:pep8]
-- 
GitLab


From 398e6ba84deffe578f1b4b3a08b7a48ad01b969d Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 10:33:15 +0000
Subject: [PATCH 14/17] Update .gitlab-ci.yml

---
 .gitlab-ci.yml | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0f8c122..52c2502 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,4 +1,4 @@
-image: clarinpl/python:3.8
+image: clarinpl/python:3.6
 
 cache:
   paths:
@@ -10,8 +10,6 @@ stages:
   - push_wheel
 
 before_script:
-  - apt-get update && apt-get install -y python3-dev
-  - pip install -r requirements.txt
   - pip install tox==2.9.1
 
 pep8:
-- 
GitLab


From db8478acc9a358a9d545a03945218528948a4d3b Mon Sep 17 00:00:00 2001
From: szymekc <szymekc98@gmail.com>
Date: Mon, 9 Nov 2020 13:12:54 +0100
Subject: [PATCH 15/17] added service help

---
 lpmn_client/src/console.py | 42 ++++++++++++++++++++++++++++++++++++++
 lpmn_services.yaml         | 37 ++++++++++++++++++++++++++++-----
 2 files changed, 74 insertions(+), 5 deletions(-)

diff --git a/lpmn_client/src/console.py b/lpmn_client/src/console.py
index 9964f43..ab8e63d 100644
--- a/lpmn_client/src/console.py
+++ b/lpmn_client/src/console.py
@@ -4,6 +4,7 @@ import configparser
 import glob as gb
 import json
 import os
+import pprint
 import readline
 import sys
 
@@ -148,6 +149,43 @@ class Console(cmd.Cmd, object):
             print("Progress file not found")
             return
 
+    def do_services(self, arg):
+        if arg in self.services.keys():
+            service = self.services[arg]
+            print("Description:")
+            print(service["description"])
+            print("\n")
+
+            if service["params"] != "None":
+                print("Available parameters:")
+                self.columnize(["name", "default", "type", "optional"], 80)
+                print("=" * 40)
+                for key, value in service["params"].items():
+                    self.columnize(
+                        [
+                            key,
+                            value["default"],
+                            value["type"],
+                            value["optional"],
+                        ],
+                        80,
+                    )
+                    print("\t", value["description"])
+                print("\n")
+
+            if service["next"] != "None":
+                print("Next in pipeline:")
+                print("=" * 40)
+                self.columnize(list(service["next"]), 80)
+                print("\n")
+
+            return
+        else:
+            print("Available LPMN services:")
+            print("=" * 40)
+            self.columnize(list(self.services.keys()), 80)
+            print("\n")
+
     def complete_upload(self, text, line, start, end):
         """Autocomplete for upload."""
         return self._complete_path(text)
@@ -169,6 +207,10 @@ class Console(cmd.Cmd, object):
         except (KeyError, IndexError):
             return [x for x in self.services.keys() if x.startswith(text)]
 
+    def complete_services(self, text, line, start, end):
+        """Autocomplete for service help."""
+        return [x for x in self.services.keys() if x.startswith(text)]
+
     def do_exit(self, s):
         """Exit the application."""
         print("\n")
diff --git a/lpmn_services.yaml b/lpmn_services.yaml
index ab4bc63..7bf8f5d 100644
--- a/lpmn_services.yaml
+++ b/lpmn_services.yaml
@@ -1,22 +1,49 @@
 any2txt:
+  description: "Changes file format to .txt."
   next:
     - service1
     - service2
+  params: None
 
 service1:
+  description: "Service1 description."
   next:
     - service3
   params:
-    - param1
-    - param2
-    - param3
+    param1:
+      default: "true"
+      type: "bool"
+      optional: "False"
+      description: "Param1 description."
+    param2:
+      default: "test"
+      type: "str"
+      optional: "True"
+      description: "Param2 description."
+    param3:
+      default: "false"
+      type: "bool"
+      optional: "True"
+      description: "Param3 description."
 
 service2:
+  description: "Service1 description."
   next:
     - service3
   params:
-    - param1
-    - param2
+    param1:
+      default: "true"
+      type: "bool"
+      optional: "False"
+      description: "Param1 description."
+    param2:
+      default: "test"
+      type: "str"
+      optional: "True"
+      description: "Param2 description."
+
 
 service3:
+  description: "Service3 description."
+  next: None
   params: None
\ No newline at end of file
-- 
GitLab


From a7fb3523bc5c5246578299555ea2d951a88b6e2d Mon Sep 17 00:00:00 2001
From: szymekc <szymekc98@gmail.com>
Date: Mon, 9 Nov 2020 13:15:01 +0100
Subject: [PATCH 16/17] pep8

---
 lpmn_client/src/console.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lpmn_client/src/console.py b/lpmn_client/src/console.py
index ab8e63d..811c706 100644
--- a/lpmn_client/src/console.py
+++ b/lpmn_client/src/console.py
@@ -4,7 +4,6 @@ import configparser
 import glob as gb
 import json
 import os
-import pprint
 import readline
 import sys
 
@@ -150,6 +149,7 @@ class Console(cmd.Cmd, object):
             return
 
     def do_services(self, arg):
+        """Service information display."""
         if arg in self.services.keys():
             service = self.services[arg]
             print("Description:")
-- 
GitLab


From 135369eae0b9940ee051377b5675b986ee744889 Mon Sep 17 00:00:00 2001
From: Szymon Ciombor <szymekc@e-science.pl>
Date: Mon, 9 Nov 2020 12:15:46 +0000
Subject: [PATCH 17/17] Update setup.py

---
 setup.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index caff30a..acaa2fd 100644
--- a/setup.py
+++ b/setup.py
@@ -5,14 +5,14 @@ with open("README.md", "r") as fh:
 
 setuptools.setup(
     name="lpmn_client",
-    version="1.2.3",
+    version="1.3.0",
     author="Szymon Ciombor",
     author_email="Szymon.Ciombor@pwr.edu.pl",
     description="CLI Client for writing LPMN queries.",
     long_description=long_description,
     long_description_content_type="text/markdown",
     packages=setuptools.find_packages(exclude="tests"),
-    python_requires=">=3.8",
+    python_requires=">=3.6",
     zip_safe=True,
     entry_points={"console_scripts": ["lpmn_client=lpmn_client.__main__:main"]},
     install_requires=["requests", "pyyaml"],
-- 
GitLab