Skip to content

Commit

Permalink
add server specification
Browse files Browse the repository at this point in the history
  • Loading branch information
seankim658 committed Jun 12, 2024
1 parent ce15182 commit 847c29a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions misc_scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Creates the `all_text` internal field in the biomarker collection used for the t

## peak_collection.py

Let's you peak into one of the collections in the database. Currently is only setup for the `tst` server. When running the script, include the flag for the collection you want to peak into. You can only peak one collection at a time. You can also optionally pass in the `-n` argument to specify how many entries you want to view (by default the last 5 entries entered into the collection are returned).
Let's you peak into one of the collections in the database. When running the script, include the flag for the collection you want to peak into. You can only peak one collection at a time. You can also optionally pass in the `-n` argument to specify how many entries you want to view (by default the last 5 entries entered into the collection are returned).

Collection flags are as follows:

Expand All @@ -35,4 +35,4 @@ Collection flags are as follows:

## check_indexes.py

Let's you check which indexes are currently setup in the target collection. Collection flags are as specified in the `peak_collection.py` file. Currently is only setup for the `tst` server.
Let's you check which indexes are currently setup in the target collection. Collection flags are as specified in the `peak_collection.py` file.
13 changes: 10 additions & 3 deletions misc_scripts/check_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import sys
import argparse

# test server port
host = "mongodb://127.0.0.1:6061"
host = "mongodb://127.0.0.1:"
tst_port = "6061"
prd_port = "7071"
db_name = "biomarkerdb_api"
db_user = "biomarkeradmin"
db_pass = "biomarkerpass"
Expand Down Expand Up @@ -40,6 +41,7 @@ def print_indexes(collection: Collection):
def main():

parser = argparse.ArgumentParser(prog="peak_collection.py")
parser.add_argument("server", help="tst/prd")
parser.add_argument(
"-b",
"--biomarker",
Expand Down Expand Up @@ -71,6 +73,11 @@ def main():
help="Store true argument for the cache collection.",
)
options = parser.parse_args()
server = options.server.lower().strip()
if server not in {"tst", "prd"}:
print("Invalid server.")
sys.exit(1)
host_w_port = f"{host}{tst_port}" if server == "tst" else f"{host}{prd_port}"
option_list = [
options.biomarker,
options.canonical_map,
Expand All @@ -90,7 +97,7 @@ def main():

try:
client = pymongo.MongoClient(
host,
host_w_port,
username=db_user,
password=db_pass,
authSource=db_name,
Expand Down
13 changes: 10 additions & 3 deletions misc_scripts/peak_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import sys
import argparse

# test server port
host = "mongodb://127.0.0.1:6061"
host = "mongodb://127.0.0.1:"
tst_port = "6061"
prd_port = "7071"
db_name = "biomarkerdb_api"
db_user = "biomarkeradmin"
db_pass = "biomarkerpass"
Expand All @@ -26,6 +27,7 @@
def main():

parser = argparse.ArgumentParser(prog="peak_collection.py")
parser.add_argument("server", help="tst/prd")
parser.add_argument(
"-b",
"--biomarker",
Expand Down Expand Up @@ -58,6 +60,11 @@ def main():
)
parser.add_argument("-n", "--num", type=int, default=5)
options = parser.parse_args()
server = options.server.lower().strip()
if server not in {"tst", "prd"}:
print("Invalid server.")
sys.exit(1)
host_w_port = f"{host}{tst_port}" if server == "tst" else f"{host}{prd_port}"
option_list = [
options.biomarker,
options.canonical_map,
Expand All @@ -77,7 +84,7 @@ def main():

try:
client = pymongo.MongoClient(
host,
host_w_port,
username=db_user,
password=db_pass,
authSource=db_name,
Expand Down

0 comments on commit 847c29a

Please sign in to comment.