Repository: golemfactory/dapp-manager (language: python)

Issue:
Remove `yagna_` prefix
We decided we'll have `dapp_manager` and `dapp_runner`, without prefixes.


Discussion / hints:

Fix patch:
diff --git a/README.md b/README.md
index 233d812..e60e764 100644
--- a/README.md
+++ b/README.md
@@ -6,11 +6,11 @@ Manage a dapp.
 This program supports shell completion for all of its commands, as well as existing dApp IDs (where applicable).
 To enable completion, use the `autocomplete` command with your shell of choice:
 ```
-$ yagna_dapp_manager autocomplete bash
+$ dapp-manager autocomplete bash
 ```
 
-**WARNING** Completion will **NOT WORK** when `autocomplete` is invoked with `python -m yagna_dapp_manager`.
-Only the installed entrypoint (i.e. `yagna_dapp_manager`) is supported. To have it available, run `poetry install`.
+**WARNING** Completion will **NOT WORK** when `autocomplete` is invoked with `python -m dapp_manager`.
+Only the installed entrypoint (i.e. `dapp-manager`) is supported. To have it available, run `poetry install`.
 
-The actual completion functions are defined in `yagna_dapp_manager/autocomplete/scripts`.
+The actual completion functions are defined in `dapp_manager/autocomplete/scripts`.
 Should the entrypoint name ever change, these files will need to be updated as well.
diff --git a/cli_sample_usage.sh b/cli_sample_usage.sh
index 8969698..e5d1a78 100755
--- a/cli_sample_usage.sh
+++ b/cli_sample_usage.sh
@@ -1,5 +1,5 @@
 function dm () {
-    python3 -m yagna_dapp_manager "$@"
+    python3 -m dapp_manager "$@"
 }
 
 echo "1. Current apps"
diff --git a/dapp_manager/__init__.py b/dapp_manager/__init__.py
new file mode 100644
index 0000000..c82af17
--- /dev/null
+++ b/dapp_manager/__init__.py
@@ -0,0 +1,2 @@
+from dapp_manager.dapp_manager import DappManager
+from dapp_manager.exceptions import UnknownApp
diff --git a/yagna_dapp_manager/__main__.py b/dapp_manager/__main__.py
similarity index 77%
rename from yagna_dapp_manager/__main__.py
rename to dapp_manager/__main__.py
index fa60d94..eb9da19 100644
--- a/yagna_dapp_manager/__main__.py
+++ b/dapp_manager/__main__.py
@@ -5,9 +5,9 @@
 
 import click
 
-from yagna_dapp_manager import DappManager
-from yagna_dapp_manager.autocomplete import install_autocomplete
-from yagna_dapp_manager.exceptions import DappManagerException
+from dapp_manager import DappManager
+from dapp_manager.autocomplete import install_autocomplete
+from dapp_manager.exceptions import DappManagerException
 
 
 def _app_id_autocomplete(_ctx, _param, incomplete):
@@ -62,6 +62,7 @@ def _cli():
 )
 @_capture_api_exceptions
 def start(descriptors: Tuple[Path], *, config: Path):
+    """Start a new app using the provided descriptor and config files."""
     dapp = DappManager.start(*descriptors, config=config)
     print(dapp.app_id)
 
@@ -69,6 +70,10 @@ def start(descriptors: Tuple[Path], *, config: Path):
 @_cli.command()
 @_capture_api_exceptions
 def list():
+    """List known app IDs (both active and dead).
+
+    The results are sorted by the apps' creation time.
+    """
     app_ids = DappManager.list()
     if app_ids:
         print("\n".join(app_ids))
@@ -77,6 +82,10 @@ def list():
 @_cli.command()
 @_capture_api_exceptions
 def prune():
+    """Remove data for non-running apps.
+
+    This removes all data related to those apps, including logs, state etc.
+    """
     app_ids = DappManager.prune()
     if app_ids:
         print("\n".join(app_ids))
@@ -93,6 +102,11 @@ def prune():
 @_with_app_id
 @_capture_api_exceptions
 def stop(*, app_id: str, timeout: int):
+    """Stop the given app gracefully.
+
+    Requests a stop from the given app through a SIGINT.
+    Optionally, a timeout (in seconds) may be given with --timeout flag.
+    """
     dapp = DappManager(app_id)
     if dapp.stop(timeout):
         print(app_id)
@@ -102,6 +116,10 @@ def stop(*, app_id: str, timeout: int):
 @_with_app_id
 @_capture_api_exceptions
 def kill(*, app_id):
+    """Stop the given app forcibly.
+
+    Stops the app's process using SIGKILL.
+    """
     dapp = DappManager(app_id)
     dapp.kill()
     print(app_id)
@@ -109,6 +127,7 @@ def kill(*, app_id):
 
 @_cli.group()
 def read():
+    """Read data stream from the given app."""
     pass
 
 
@@ -117,6 +136,7 @@ def read():
 @_capture_api_exceptions
 @_with_ensure_alive
 def state(*, app_id, ensure_alive):
+    """Read the state stream of the given app."""
     dapp = DappManager(app_id)
     print(dapp.read_file("state", ensure_alive))
 
@@ -126,6 +146,7 @@ def state(*, app_id, ensure_alive):
 @_capture_api_exceptions
 @_with_ensure_alive
 def data(*, app_id, ensure_alive):
+    """Read the data stream of the given app."""
     dapp = DappManager(app_id)
     print(dapp.read_file("data", ensure_alive))
 
@@ -135,6 +156,7 @@ def data(*, app_id, ensure_alive):
 @_capture_api_exceptions
 @_with_ensure_alive
 def log(*, app_id, ensure_alive):
+    """Read the log stream of a given app."""
     dapp = DappManager(app_id)
     print(dapp.read_file("log", ensure_alive))
 
@@ -144,6 +166,7 @@ def log(*, app_id, ensure_alive):
 @_capture_api_exceptions
 @_with_ensure_alive
 def stdout(*, app_id, ensure_alive):
+    """Read the stdout of a given app."""
     dapp = DappManager(app_id)
     print(dapp.read_file("stdout", ensure_alive))
 
@@ -153,6 +176,7 @@ def stdout(*, app_id, ensure_alive):
 @_capture_api_exceptions
 @_with_ensure_alive
 def stderr(*, app_id, ensure_alive):
+    """Read the stderr of a given app."""
     dapp = DappManager(app_id)
     print(dapp.read_file("stderr", ensure_alive))
 
@@ -167,9 +191,9 @@ def stderr(*, app_id, ensure_alive):
     help="Path to the file to which the shell completion function should be added.",
 )
 def autocomplete(shell: str, path: Path):
-    """Enable shell completion by registering an appropriate shell function.
+    """Enable CLI shell completion for the given shell.
 
-    This command works by appending a predefined piece of shell code to the user's
+    This command works by appending a pre-defined piece of shell code to the user's
     shell configuration file.
 
     The default target file will depend on the selected shell type (bash, fish or zsh):
diff --git a/yagna_dapp_manager/autocomplete/__init__.py b/dapp_manager/autocomplete/__init__.py
similarity index 97%
rename from yagna_dapp_manager/autocomplete/__init__.py
rename to dapp_manager/autocomplete/__init__.py
index 890880d..b331eb5 100644
--- a/yagna_dapp_manager/autocomplete/__init__.py
+++ b/dapp_manager/autocomplete/__init__.py
@@ -6,7 +6,7 @@
 # Entrypoint aka binary name aka script name
 # Entrypoint must match the name defined in pyproject.toml under
 # [tool.poetry.scripts] section
-ENTRYPOINT = "yagna_dapp_manager"
+ENTRYPOINT = "dapp-manager"
 COMPLETION_FUNC_NAME = f"{ENTRYPOINT}_completion"
 SCRIPTS_DIR = Path(__file__).parent / "scripts"
 
diff --git a/yagna_dapp_manager/autocomplete/scripts/.yagna_dapp_manager.bash b/dapp_manager/autocomplete/scripts/.dapp-manager.bash
similarity index 75%
rename from yagna_dapp_manager/autocomplete/scripts/.yagna_dapp_manager.bash
rename to dapp_manager/autocomplete/scripts/.dapp-manager.bash
index 950688e..051ecd4 100644
--- a/yagna_dapp_manager/autocomplete/scripts/.yagna_dapp_manager.bash
+++ b/dapp_manager/autocomplete/scripts/.dapp-manager.bash
@@ -1,9 +1,9 @@
 
-_yagna_dapp_manager_completion() {
+_dapp_manager_completion() {
     local IFS=$'\n'
     local response
 
-    response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _YAGNA_DAPP_MANAGER_COMPLETE=bash_complete $1)
+    response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _DAPP_MANAGER_COMPLETE=bash_complete $1)
 
     for completion in $response; do
         IFS=',' read type value <<< "$completion"
@@ -22,5 +22,5 @@ _yagna_dapp_manager_completion() {
     return 0
 }
 
-complete -o nosort -F _yagna_dapp_manager_completion yagna_dapp_manager
+complete -o nosort -F _dapp_manager_completion dapp-manager
 
diff --git a/yagna_dapp_manager/autocomplete/scripts/.yagna_dapp_manager.fish b/dapp_manager/autocomplete/scripts/.dapp-manager.fish
similarity index 61%
rename from yagna_dapp_manager/autocomplete/scripts/.yagna_dapp_manager.fish
rename to dapp_manager/autocomplete/scripts/.dapp-manager.fish
index 50e81cc..ca16565 100644
--- a/yagna_dapp_manager/autocomplete/scripts/.yagna_dapp_manager.fish
+++ b/dapp_manager/autocomplete/scripts/.dapp-manager.fish
@@ -1,8 +1,8 @@
 
-function _yagna_dapp_manager_completion;
+function _dapp_manager_completion;
     set -l response;
 
-    for value in (env _YAGNA_DAPP_MANAGER_COMPLETE=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) yagna_dapp_manager);
+    for value in (env _DAPP_MANAGER_COMPLETE=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) dapp-manager);
         set response $response $value;
     end;
 
@@ -19,5 +19,5 @@ function _yagna_dapp_manager_completion;
     end;
 end;
 
-complete --no-files --command yagna_dapp_manager --arguments "(_yagna_dapp_manager_completion)";
+complete --no-files --command dapp-manager --arguments "(_dapp_manager_completion)";
 
diff --git a/yagna_dapp_manager/autocomplete/scripts/.yagna_dapp_manager.zsh b/dapp_manager/autocomplete/scripts/.dapp-manager.zsh
similarity index 75%
rename from yagna_dapp_manager/autocomplete/scripts/.yagna_dapp_manager.zsh
rename to dapp_manager/autocomplete/scripts/.dapp-manager.zsh
index 319ed15..f9dbf27 100644
--- a/yagna_dapp_manager/autocomplete/scripts/.yagna_dapp_manager.zsh
+++ b/dapp_manager/autocomplete/scripts/.dapp-manager.zsh
@@ -1,13 +1,13 @@
 
-#compdef yagna_dapp_manager
+#compdef dapp-manager
 
-_yagna_dapp_manager_completion() {
+_dapp_manager_completion() {
     local -a completions
     local -a completions_with_descriptions
     local -a response
-    (( ! $+commands[yagna_dapp_manager] )) && return 1
+    (( ! $+commands[dapp-manager] )) && return 1
 
-    response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _YAGNA_DAPP_MANAGER_COMPLETE=zsh_complete yagna_dapp_manager)}")
+    response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _DAPP_MANAGER_COMPLETE=zsh_complete dapp-manager)}")
 
     for type key descr in ${response}; do
         if [[ "$type" == "plain" ]]; then
@@ -32,5 +32,5 @@ _yagna_dapp_manager_completion() {
     fi
 }
 
-compdef _yagna_dapp_manager_completion yagna_dapp_manager;
+compdef _dapp_manager_completion dapp-manager;
 
diff --git a/yagna_dapp_manager/dapp_manager.py b/dapp_manager/dapp_manager.py
similarity index 100%
rename from yagna_dapp_manager/dapp_manager.py
rename to dapp_manager/dapp_manager.py
diff --git a/yagna_dapp_manager/dapp_starter.py b/dapp_manager/dapp_starter.py
similarity index 100%
rename from yagna_dapp_manager/dapp_starter.py
rename to dapp_manager/dapp_starter.py
diff --git a/yagna_dapp_manager/exceptions.py b/dapp_manager/exceptions.py
similarity index 93%
rename from yagna_dapp_manager/exceptions.py
rename to dapp_manager/exceptions.py
index 569c5eb..abcdd38 100644
--- a/yagna_dapp_manager/exceptions.py
+++ b/dapp_manager/exceptions.py
@@ -1,5 +1,5 @@
 class DappManagerException(Exception):
-    """Base exception for all yagna-dapp-manager exceptions"""
+    """Base exception for all dapp-manager exceptions"""
 
     SHELL_EXIT_CODE = 3
 
diff --git a/yagna_dapp_manager/py.typed b/dapp_manager/py.typed
similarity index 100%
rename from yagna_dapp_manager/py.typed
rename to dapp_manager/py.typed
diff --git a/yagna_dapp_manager/storage.py b/dapp_manager/storage.py
similarity index 100%
rename from yagna_dapp_manager/storage.py
rename to dapp_manager/storage.py
diff --git a/pyproject.toml b/pyproject.toml
index 1bbf82f..b64f78f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,5 +1,5 @@
 [tool.poetry]
-name = "yagna-dapp-manager"
+name = "dapp-manager"
 version = "0.0.1"
 description = "Golem dapp-manager - run decetralized apps on the Golem Network using a 'docker-compose'-like interface"
 authors = ["Golem Factory <contact@golem.network>"]
@@ -32,7 +32,7 @@ pytest = "^7.1"
 pytest-cov = "^3.0.0"
 
 [tool.poetry.scripts]
-yagna_dapp_manager = "yagna_dapp_manager.__main__:main"
+dapp-manager = "dapp_manager.__main__:main"
 
 [tool.poe.tasks]
 codestyle = "black --check --diff ."
diff --git a/sample_usage.py b/sample_usage.py
index 7019be0..581b1f6 100644
--- a/sample_usage.py
+++ b/sample_usage.py
@@ -1,4 +1,4 @@
-from yagna_dapp_manager import DappManager
+from dapp_manager import DappManager
 
 #   New app
 dapp = DappManager.start("golem_compose.yml", config="config_file.yml")
diff --git a/yagna_dapp_manager/__init__.py b/yagna_dapp_manager/__init__.py
deleted file mode 100644
index 5e3fbcc..0000000
--- a/yagna_dapp_manager/__init__.py
+++ /dev/null
@@ -1,2 +0,0 @@
-from yagna_dapp_manager.dapp_manager import DappManager
-from yagna_dapp_manager.exceptions import UnknownApp


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
index 48fde9c..1674bdb 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -1,7 +1,7 @@
 import pytest
 import tempfile
 
-from yagna_dapp_manager import DappManager
+from dapp_manager import DappManager
 
 
 @pytest.fixture(autouse=True)
diff --git a/tests/helpers.py b/tests/helpers.py
index a2f077c..81c85e2 100644
--- a/tests/helpers.py
+++ b/tests/helpers.py
@@ -2,7 +2,7 @@
 import psutil
 from typing import List, Tuple, Union
 
-from yagna_dapp_manager import DappManager
+from dapp_manager import DappManager
 
 
 def process_is_running(pid: int) -> bool:
@@ -35,7 +35,7 @@ def _get_command(self):
         return command
 
     with mock.patch(
-        "yagna_dapp_manager.dapp_starter.DappStarter._get_command", new=_get_command
+        "dapp_manager.dapp_starter.DappStarter._get_command", new=_get_command
     ):
         return DappManager.start(descriptor_file, config=config_file)
 
diff --git a/tests/test_manager_api.py b/tests/test_manager_api.py
index 9b62482..38df1ef 100644
--- a/tests/test_manager_api.py
+++ b/tests/test_manager_api.py
@@ -3,8 +3,8 @@
 import pytest
 from time import sleep
 
-from yagna_dapp_manager import DappManager
-from yagna_dapp_manager.exceptions import UnknownApp, AppNotRunning
+from dapp_manager import DappManager
+from dapp_manager.exceptions import UnknownApp, AppNotRunning
 
 from .helpers import (
     start_dapp,