Skip to content

Commit

Permalink
added requirement test to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Feb 26, 2024
1 parent 6506df2 commit 96ca0a8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 15 deletions.
19 changes: 17 additions & 2 deletions bedboss/bedboss.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import peppy
from eido import validate_project
import bbconf
import subprocess

import pephubclient
from pephubclient import PEPHubClient
Expand Down Expand Up @@ -113,6 +114,18 @@ def load_to_s3(
pm.run(cmd=command, lock_name="s3_sync_bedstat")


def requirements_check() -> None:
"""
Check if all requirements are installed
:return: None
"""
_LOGGER.info("Checking requirements...")
subprocess.run(
["bash", f"{os.path.dirname(os.path.abspath(__file__))}/requirements_test.sh"]
)


def run_all(
sample_name: str,
input_file: str,
Expand Down Expand Up @@ -433,13 +446,13 @@ def main(test_args: dict = None) -> NoReturn:
or "test_outfolder",
)
pm_out_folder = os.path.join(os.path.abspath(pm_out_folder[0]), "pipeline_manager")

pm = pypiper.PipelineManager(
name="bedboss-pipeline",
outfolder=pm_out_folder,
version=__version__,
args=args,
# args=args,
multi=args_dict.get("multy", False),
recover=True,
)
if args_dict["command"] == "all":
run_all(pm=pm, **args_dict)
Expand All @@ -455,6 +468,8 @@ def main(test_args: dict = None) -> NoReturn:
run_bedbuncher(pm=pm, **args_dict)
elif args_dict["command"] == "index":
add_to_qdrant(pm=pm, **args_dict)
elif args_dict["command"] == "requirements-check":
requirements_check()
else:
parser.print_help()
# raise Exception("Incorrect pipeline name.")
Expand Down
10 changes: 5 additions & 5 deletions bedboss/bedbuncher/bedbuncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ def run_bedbuncher(
return None


if __name__ == "__main__":
run_bedbuncher(
"/media/alex/Extreme SSD/databio/repos/bedbase_all/bedhost/bedbase_configuration_compose.yaml",
"databio/excluderanges:id3",
)
# if __name__ == "__main__":
# run_bedbuncher(
# "/media/alex/Extreme SSD/databio/repos/bedbase_all/bedhost/bedbase_configuration_compose.yaml",
# "databio/excluderanges:id3",
# )
4 changes: 4 additions & 0 deletions bedboss/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def build_argparser() -> ArgumentParser:
"index", help="Index not indexed bed files and add them to the qdrant database "
)

subparser.add_parser(
"requirements-check", help="Check if all requirements are installed"
)

sub_all.add_argument(
"--outfolder",
required=True,
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format.

## [0.1.0a1] - 2023-08-02
## [0.1.0] - 2024-01-26
### Added
- Initial alpha release
18 changes: 11 additions & 7 deletions test/test_bedboss.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from bedboss.bedboss import main
import bedboss
import os
import warnings
import subprocess
Expand All @@ -13,7 +14,9 @@
)

BEDBASE_CONFIG = os.path.join(FILE_DIR, "test_dependencies", "bedbase_config_test.yaml")
DEPENDENCIES_TEST_SCRIPT = f"{FILE_DIR}/bash_requirements_test.sh"
DEPENDENCIES_TEST_SCRIPT = (
f"{os.path.dirname(os.path.abspath(bedboss.__file__))}/requirements_test.sh"
)

pytest_db_skip_reason = "Database is not set up... To run this test, set up the database. Go to test/README.md for more information."

Expand All @@ -23,16 +26,17 @@ def check_dependencies_installed() -> bool:
print("Testing dependencies...")
# key = "PATH"
# value = os.getenv(key)
test_dep_return_code = subprocess.run([DEPENDENCIES_TEST_SCRIPT], shell=True)
if not (1 > test_dep_return_code.returncode):
test_dep_return_code = subprocess.run(["bash", DEPENDENCIES_TEST_SCRIPT])
if test_dep_return_code.returncode == 127:
raise Exception(f"test script '{DEPENDENCIES_TEST_SCRIPT}' doesn't exist.")
elif not (1 > test_dep_return_code.returncode):
warnings.warn(UserWarning(f"{pytest_db_skip_reason}"))
return False
return True
# return 1 > test_dep_return_code.returncode


# dependencies_installed = check_dependencies_installed()
dependencies_installed = True
dependencies_installed = check_dependencies_installed()


def db_setup():
Expand All @@ -45,8 +49,8 @@ def db_setup():
return True


# def test_dependencies():
# assert dependencies_installed
def test_dependencies():
assert dependencies_installed


@pytest.mark.parametrize(
Expand Down

0 comments on commit 96ca0a8

Please sign in to comment.