Repository: iossifovlab/gpf

Issue:
[ENH] Imporvements in `grr_browse`
- [x] dump GRR configuration in YAML format
- [x] make `--print-grr` default behavior

Discussion:

Patch:
diff --git a/dae/dae/genomic_resources/cli.py b/dae/dae/genomic_resources/cli.py
index a07e9a55c..adaef7470 100644
--- a/dae/dae/genomic_resources/cli.py
+++ b/dae/dae/genomic_resources/cli.py
@@ -5,7 +5,6 @@ import logging
 import argparse
 import pathlib
 import copy
-import pprint
 
 from typing import Dict, Union
 from urllib.parse import urlparse
@@ -767,12 +766,6 @@ def cli_browse(cli_args=None):
         help="Print the resource size in bytes"
     )
 
-    parser.add_argument(
-        "--print-grr",
-        default=False,
-        action="store_true",
-        help="Print the path and content of the GRR definition to be used"
-    )
 
     if cli_args is None:
         cli_args = sys.argv[1:]
@@ -789,12 +782,12 @@ def cli_browse(cli_args=None):
             if definition_path is not None \
             else DEFAULT_DEFINITION
 
-    if args.print_grr:
-        if definition_path is not None:
-            print("Working with GRR definition:", definition_path)
-        else:
-            print("No GRR definition found, using the DEFAULT_DEFINITION")
-        pprint.pprint(definition)
+
+    if definition_path is not None:
+        print("Working with GRR definition:", definition_path)
+    else:
+        print("No GRR definition found, using the DEFAULT_DEFINITION")
+    print(yaml.safe_dump(definition, sort_keys=False))
 
     repo = build_genomic_resource_repository(definition=definition)
     _run_list_command(repo, args)


Test patch:
diff --git a/dae/dae/genomic_resources/tests/test_cli_browse.py b/dae/dae/genomic_resources/tests/test_cli_browse.py
index 4f58f0c36..7cb2af9f9 100644
--- a/dae/dae/genomic_resources/tests/test_cli_browse.py
+++ b/dae/dae/genomic_resources/tests/test_cli_browse.py
@@ -55,6 +55,10 @@ def test_cli_browse_with_grr_argument(repo_fixture, repo_def, capsys):
 
     assert err == ""
     assert out == \
+        f"Working with GRR definition: {str(repo_def)}\n" \
+        "id: test_grr\n" \
+        "type: directory\n" \
+        f"directory: {str(repo_fixture[0])}\n\n" \
         "Basic                0        2 7.0 B        test_grr one\n" \
         "gene_models          1.0      2 50.0 B       test_grr sub/two\n"
 
@@ -69,6 +73,10 @@ def test_cli_browse_with_env_variable(repo_fixture, repo_def, capsys, mocker):
 
     assert err == ""
     assert out == \
+        f"Working with GRR definition: {str(repo_def)}\n" \
+        "id: test_grr\n" \
+        "type: directory\n" \
+        f"directory: {str(repo_fixture[0])}\n\n" \
         "Basic                0        2 7.0 B        test_grr one\n" \
         "gene_models          1.0      2 50.0 B       test_grr sub/two\n"
 
@@ -81,7 +89,13 @@ def test_cli_browse_default_defintion(repo_fixture, repo_def, capsys, mocker):
     cli_browse([])
     out, err = capsys.readouterr()
 
+    print(out, str(repo_fixture)[0])
+
     assert err == ""
     assert out == \
+        f"Working with GRR definition: {str(repo_def)}\n" \
+        "id: test_grr\n" \
+        "type: directory\n" \
+        f"directory: {str(repo_fixture[0])}\n\n" \
         "Basic                0        2 7.0 B        test_grr one\n" \
         "gene_models          1.0      2 50.0 B       test_grr sub/two\n"