Repository: sunbeam-labs/sunbeam

Issue:
Improve logging consistency
**What's the feature?**
At the moment logging is a little fractured between snakemake's `log` and `stdout/stderr`. The former is better in local execution situations while the latter is better when it comes to clusters. Would be nice to have one solution that works for both and eliminates any redundancies.

Would also be nice to include automatically in rules instead of having to write the same lines over and over (and benchmarking).

Discussion:

Solution patch:
diff --git a/sunbeam/project/sunbeam_config.py b/sunbeam/project/sunbeam_config.py
index 55a21aa..6cac316 100644
--- a/sunbeam/project/sunbeam_config.py
+++ b/sunbeam/project/sunbeam_config.py
@@ -1,3 +1,4 @@
+import os
 import yaml
 from pathlib import Path
 from sunbeam import __version__, EXTENSIONS_DIR
@@ -144,7 +145,12 @@ class SunbeamConfig:
                 resolved[key] = {}
                 for sub_key, sub_value in value.items():
                     if sub_key.endswith("_fp"):
-                        if not Path(sub_value).is_absolute():
+                        if not sub_value:
+                            print(
+                                f"Warning: {key}.{sub_key} is empty, setting to os.devnull"
+                            )
+                            resolved[key][sub_key] = Path(os.devnull)
+                        elif not Path(sub_value).is_absolute():
                             resolved[key][sub_key] = root_fp / sub_value
                         else:
                             resolved[key][sub_key] = Path(sub_value).resolve()


Test patch:
diff --git a/tests/unit/test_sunbeam_config.py b/tests/unit/test_sunbeam_config.py
index 4d5d27d..4bbb35d 100644
--- a/tests/unit/test_sunbeam_config.py
+++ b/tests/unit/test_sunbeam_config.py
@@ -1,3 +1,4 @@
+import os
 import pytest
 import yaml
 from pathlib import Path
@@ -126,7 +127,7 @@ def test_fill_missing_doesnt_overwrite(test_extension):
     assert sc.config["sbx_test_extension"]["bloop"] == "not_blorp"
 
 
-def test_modify(tmp_path):
+def test_modify():
     config = {
         "all": {
             "root": "/path/to/root",
@@ -142,7 +143,7 @@ def test_modify(tmp_path):
     assert sc.config["sbx_test_extension"]["bloop"] == "new_value"
 
 
-def test_modify_one_of_many(tmp_path):
+def test_modify_one_of_many():
     config = {
         "all": {
             "root": "/path/to/root",
@@ -158,3 +159,32 @@ def test_modify_one_of_many(tmp_path):
     sc.modify("sbx_test_extension: {bloop: 'new_value'}")
     assert sc.config["sbx_test_extension"]["bloop"] == "new_value"
     assert sc.config["sbx_test_extension"]["blap"] == "blip"
+
+
+def test_empty_fp(tmp_path):
+    config_fp = tmp_path / "config.yml"
+
+    with open(config_fp, "w") as f:
+        f.write(
+            """
+            all:
+                root: /path/to/root
+                version: 1.0.0
+            sbx_test_extension:
+                bloop_fp: /path/to/bloop_fp
+                blap_fp: ""
+                blip_fp: 
+        """
+        )
+
+    sc = SunbeamConfig.from_file(config_fp)
+
+    assert sc.config["sbx_test_extension"]["bloop_fp"] == "/path/to/bloop_fp"
+    assert sc.config["sbx_test_extension"]["blap_fp"] == ""
+    assert sc.config["sbx_test_extension"]["blip_fp"] == None
+
+    res = sc.resolved_paths()
+
+    assert res["sbx_test_extension"]["bloop_fp"] == Path("/path/to/bloop_fp")
+    assert res["sbx_test_extension"]["blap_fp"] == Path(os.devnull)
+    assert res["sbx_test_extension"]["blip_fp"] == Path(os.devnull)