Skip to content

work toward implementing drs #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions bbconf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import logmuse

from bbconf._version import __version__
from bbconf.bbconf import *
from bbconf.const import *

__all__ = ["BedBaseConf", "get_bedbase_cfg"]

logmuse.init_logger("bbconf")
40 changes: 38 additions & 2 deletions bbconf/bbconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@
from bbconf.exceptions import MissingConfigDataError, BedBaseConfError
from bbconf.helpers import raise_missing_key, get_bedbase_cfg

os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" # to suppress verbose warnings tensorflow
# os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3" # to suppress verbose warnings tensorflow
from geniml.text2bednn import text2bednn
from geniml.search import QdrantBackend
from sentence_transformers import SentenceTransformer
from geniml.region2vec import Region2VecExModel
from geniml.io import RegionSet

_LOGGER = getLogger(PKG_NAME)
_LOGGER = getLogger(__name__)

DRS_ACCESS_URL = "{server_url}/objects/{object_id}/access/{access_id}"


class BedBaseConf:
Expand Down Expand Up @@ -593,3 +595,37 @@ def get_prefixed_uri(self, postfix: str, remote_class: str = "http") -> str:
:return: full uri path
"""
return os.path.join(self.prefix(remote_class), postfix)

def get_bed_drs_metadata(object_id: str) -> dict:
bed_metadata = self.bed.retrieve(object_id)
drs_dict = {
"id": object_id,
"size": bed_metadata["file_size"],
"created_time": bed_metadata["created_time"],
"checksums": object_id,
"access_methods": [],
}
# add access method for each remote class
for access_id in keys(self.config[CFG_REMOTE_KEY]):
access_dict = {
"type": "https",
"access_id": access_id,
"access_url": DRS_ACCESS_URL.format(
server_url=self.config["access_methods"][access_id]["server_url"],
object_id=object_id,
access_id=access_id,
),
}
access_dict["region"] = (
self.config["access_methods"][access_id]["region"] or None
)
drs_dict["access_methods"].append(access_dict)
return drs_dict

def get_bed_url(object_id: str, access_id: str) -> str:
access_url = DRS_ACCESS_URL.format(
server_url=self.config["access_methods"][access_id]["server_url"],
object_id=object_id,
access_id=access_id,
)
return access_url
31 changes: 31 additions & 0 deletions interactive_testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This provides a short script to explore bbconf interactively
# First you have to set the env vars with something like:
# source ../bedbase.org/environment/production.env

from bbconf import BedBaseConf

import logging
import sys

def set_up_interactive_logger(package=None) -> logging.Logger:
"""Set up a logger for interactive testing"""
_LOGGER = logging.getLogger(package)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
stream = logging.StreamHandler(sys.stdout)
stream.setFormatter(formatter)
stream.setLevel(logging.DEBUG)
_LOGGER.addHandler(stream)
_LOGGER.setLevel(logging.DEBUG)
return _LOGGER

_LOGGER = set_up_interactive_logger()
_LOGGER.debug("Test log message")


bbc = BedBaseConf("../bedbase.org/config/bedbase.yaml")

bbc.bed.retrieve("78c0e4753d04b238fc07e4ebe5a02984")

bbc.bed.retrieve("78c0e4753d04b238fc07e4ebe5a02984", "bedfile")

bbc.bed.retrieve("78c0e4753d04b238fc07e4ebe5a02984", result_identifier="bedfile")
1 change: 0 additions & 1 deletion requirements/requirements-all.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
logmuse
yacman>=0.9.1
pipestat>=0.6.0a2
#pipestat @ git+https://github.com/pepkit/pipestat@dev#egg=pipestat
Expand Down