Skip to content

Commit 48c7b57

Browse files
committed
Make test_add_simulation working without ROOT
1 parent d875f55 commit 48c7b57

4 files changed

Lines changed: 35 additions & 25 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools>=77", "setuptools_scm>=8", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
6-
authors = [{name = "fooo"}]
6+
authors = [{name = "NMRlipids Open Collaboration"}]
77
classifiers = [
88
"Development Status :: 4 - Beta",
99
"Environment :: Console",

src/DatabankLib/__init__.py

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
DatabankLib package.
2+
DatabankLib package for NMRlipids Databank project.
33
44
Here we define the main package variables and constants used throughout the NMRlipids
55
Databank project.
@@ -8,11 +8,11 @@
88

99
import os
1010

11-
from ._version import __version__ # noqa: F401
11+
from ._version import __version__
1212

1313
# Package Information
1414

15-
__author__ = "NMRlipids open collaboration"
15+
__author__ = "NMRlipids Open Collaboration"
1616

1717
__author_email__ = "samuli.ollila@helsinki.fi"
1818

@@ -22,21 +22,17 @@
2222
"the NMRlipids Databank."
2323
)
2424

25+
__license__ = "GPL-v3"
26+
2527
__url__ = "https://github.com/NMRlipids/Databank"
2628

2729
# Global Paths
2830

29-
NMLDB_ROOT_PATH: str = os.environ.get(
30-
"NMLDB_ROOT_PATH",
31-
os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))),
32-
)
33-
""" Path to the project root """
34-
3531
NMLDB_DATA_PATH: str = os.environ.get(
3632
"NMLDB_DATA_PATH",
37-
os.path.join(NMLDB_ROOT_PATH, "Data"),
33+
os.path.join(os.getcwd(), "BilayerData"),
3834
)
39-
""" Path to the project data folder """
35+
""" Path to the Databank Data folder """
4036

4137
NMLDB_SIMU_PATH: str = os.environ.get(
4238
"NMLDB_SIMU_PATH",
@@ -50,13 +46,6 @@
5046
NMLDB_EXP_PATH: str = os.path.join(NMLDB_DATA_PATH, "experiments")
5147
""" Path to the project experiments folder """
5248

53-
if not os.path.isdir(NMLDB_DATA_PATH):
54-
raise RuntimeError(
55-
"Seems that you installed package in a non-debug mode. "
56-
"In this case you *must* set NMLDB_ROOT_PATH explicitly "
57-
"to git-clonned `Databank` folder.",
58-
)
59-
6049
# Universal return codes
6150

6251
RCODE_SKIPPED: int = 0
@@ -67,3 +56,25 @@
6756

6857
RCODE_ERROR: int = 2
6958
""" Success code 2: calculation failed """
59+
60+
print(
61+
f"DatabankLib {__version__} by {__author__} - {__license__}",
62+
)
63+
64+
if os.path.isdir(NMLDB_DATA_PATH):
65+
from DatabankLib.settings import molecules
66+
67+
_ = len(molecules.lipids_set)
68+
print(
69+
f"NMRlipids Databank is initialized from the folder: {NMLDB_DATA_PATH}\n"
70+
"---------------------------------------------------------------",
71+
)
72+
else:
73+
msg = f"""
74+
Error: no data folder {NMLDB_DATA_PATH}.
75+
If Data folder was not created, please create it by using
76+
$ nml_initialize_data.py toy
77+
OR
78+
$ nml_initialize_data.py stable
79+
and then specify by NMLDB_DATA_PATH environment variable."""
80+
raise RuntimeError(msg)

tests/conftest.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,7 @@ def header_module_scope(request):
4444
# Default to nodata:
4545
if sim_key is None:
4646
cmdopt = request.config.getoption("--cmdopt")
47-
if cmdopt in SIM_MAP:
48-
sim_key = cmdopt
49-
else:
50-
sim_key = "nodata"
47+
sim_key = cmdopt if cmdopt in SIM_MAP else "nodata"
5148

5249
data_root = os.path.join(os.path.dirname(__file__), "Data")
5350
os.environ["NMLDB_DATA_PATH"] = data_root
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
`test_adddata.py` perform regression testing of adding-data functionality
2+
Perform integration testing of adding-simulation functionality.
33
44
NOTE: globally import of DatabankLib is **STRICTLY FORBIDDEN** because it
55
breaks the substitution of global path folders
@@ -32,7 +32,9 @@ def setup_class(cls):
3232

3333
if os.path.isfile(os.path.join(DatabankLib.NMLDB_DATA_PATH, ".notest")):
3434
pytest.exit("Test are corrupted. I see '.notest' file in the data folder.")
35-
cls.exe = os.path.join(DatabankLib.NMLDB_ROOT_PATH, "src", "DatabankLib", "bin", "add_simulation.py")
35+
cls.exe = os.path.join(
36+
os.path.dirname(os.path.dirname(__file__)), "src", "DatabankLib", "bin", "add_simulation.py"
37+
)
3638
cls.out_dir = DatabankLib.NMLDB_SIMU_PATH
3739
os.mkdir(cls.out_dir)
3840

0 commit comments

Comments
 (0)