Skip to content

Commit

Permalink
Fixes issue #1087
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Nov 15, 2024
1 parent 52ab3a5 commit 6bc38d0
Show file tree
Hide file tree
Showing 8 changed files with 89 additions and 90 deletions.
12 changes: 12 additions & 0 deletions .envs/.local/.django
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,15 @@ LRM_QA_PASSWORD=''
#--------------------------------------------------------------------------------
LRM_DEV_TOKEN=''
XLI_TOKEN=''
TEST_SERVER_TOKEN=''

#Server Base_URLs
#--------------------------------------------------------------------------------
BASE_URL_DEV=http://sde-renaissance.nasa-impact.net
BASE_URL_TEST=https://sciencediscoveryengine.test.nasa.gov
BASE_URL_PROD=https://sciencediscoveryengine.nasa.gov
BASE_URL_XLI=http://sde-xli.nasa-impact.net
BASE_URL_LRM_DEV=https://sde-lrm.nasa-impact.net
BASE_URL_LRM_QA=https://sde-qa.nasa-impact.net
BASE_URL_TEST_SERVER=http://10.51.14.135
BASE_URL_REN=http://sde-renaissance.nasa-impact.net
64 changes: 64 additions & 0 deletions config/server_configs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import os

server_configs = {
"dev": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": os.getenv('BASE_URL_DEV'),
"index": "sde_index",
},
"test": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": os.getenv('BASE_URL_TEST'),
"index": "sde_index",
},
"production": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": os.getenv('BASE_URL_PROD'),
"index": "sde_index",
},
"secret_test": {
"app_name": "nasa-sba-sde",
"query_name": "query-sde-primary",
"base_url": os.getenv('BASE_URL_TEST'),
"index": "sde_index",
},
"secret_production": {
"app_name": "nasa-sba-sde",
"query_name": "query-sde-primary",
"base_url": os.getenv('BASE_URL_PROD'),
"index": "sde_index",
},
"xli": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": os.getenv('BASE_URL_XLI'),
"index": "sde_index",
},
"lrm_dev": {
"app_name": "sde-init-check",
"query_name": "query-init-check",
"base_url": os.getenv('BASE_URL_LRM_DEV'),
"index": "sde_init_check",
},
"lrm_qa": {
"app_name": "sde-init-check",
"query_name": "query-init-check",
"base_url": os.getenv('BASE_URL_LRM_QA'),
"index": "sde_init_check",
},
"ren_server": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": os.getenv('BASE_URL_REN'),
"index": "sde_index",
},
"test_server": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": os.getenv('BASE_URL_TEST_SERVER'),
"index": "sde_index",
},
}
17 changes: 1 addition & 16 deletions config_generation/api.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,8 @@
from typing import Any

from config.server_configs import server_configs
import requests

from config import tokens

server_configs: dict[str, dict[str, str]] = {
"ren_server": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": "http://sde-renaissance.nasa-impact.net",
},
"test_server": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": "http://10.51.14.135",
},
}


class Api:
def __init__(self, server_name: str) -> None:
self.headers: dict[str, str] = {"Authorization": f"Bearer {tokens[server_name]}"}
Expand Down
15 changes: 1 addition & 14 deletions config_generation/minimum_api.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
from typing import Any

from config.server_configs import server_configs
import requests

server_configs: dict[str, dict[str, str]] = {
"test_server": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": "https://sciencediscoveryengine.test.nasa.gov",
},
"production_server": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": "https://sciencediscoveryengine.nasa.gov",
},
}


class Api:
def __init__(self, server_name: str = "test", token: str = None) -> None:
Expand Down
6 changes: 3 additions & 3 deletions functional_tests/check_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import time
import urllib.parse

import os
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
Expand All @@ -16,8 +16,8 @@

def server_url(config_folder, server="test", secret=True) -> str:
URLS = {
"test": "https://sciencediscoveryengine.test.nasa.gov",
"prod": "https://sciencediscoveryengine.nasa.gov",
"test": os.getenv('BASE_URL_TEST'),
"prod": os.getenv('BASE_URL_PROD'),
}
if secret:
query = "query-sde-primary"
Expand Down
7 changes: 4 additions & 3 deletions scripts/ej/cmr_to_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import json
import urllib.parse

from config.server_configs import server_configs
import os
from environmental_justice.models import EnvironmentalJusticeRow


Expand All @@ -22,15 +23,15 @@ def concept_id_to_sinequa_id(concept_id: str) -> str:


def sinequa_id_to_url(sinequa_id: str) -> str:
base_url = "https://sciencediscoveryengine.nasa.gov/app/nasa-sba-smd/#/preview"
base_domain = os.getenv('BASE_URL_PROD')
base_url = f"{base_domain}/app/nasa-sba-smd/#/preview"
query = '{"name":"query-smd-primary","scope":"All","text":""}'

encoded_id = urllib.parse.quote(sinequa_id, safe="")
encoded_query = urllib.parse.quote(query, safe="")

return f"{base_url}?id={encoded_id}&query={encoded_query}"


def categorize_processing_level(level):
advanced_analysis_levels = {"0", "Level 0", "NA", "Not Provided", "Not provided"}

Expand Down
6 changes: 3 additions & 3 deletions sde_collections/models/collection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import urllib.parse

import os
import requests
from django.contrib.auth import get_user_model
from django.db import models
Expand Down Expand Up @@ -129,7 +129,7 @@ def tree_root(self) -> str:

@property
def server_url_secret_prod(self) -> str:
base_url = "https://sciencediscoveryengine.nasa.gov" # noqa: E231
base_url = os.getenv('BASE_URL_SECRET_TEST') # noqa: E231
payload = {
"name": "secret-prod",
"scope": "All",
Expand All @@ -143,7 +143,7 @@ def server_url_secret_prod(self) -> str:

@property
def server_url_prod(self) -> str:
base_url = "https://sciencediscoveryengine.nasa.gov" # noqa: E231
base_url = os.getenv('BASE_URL_PROD') # noqa: E231
payload = {
"name": "query-smd-primary",
"scope": "All",
Expand Down
52 changes: 1 addition & 51 deletions sde_collections/sinequa_api.py
Original file line number Diff line number Diff line change
@@ -1,62 +1,12 @@
import json
from typing import Any

from config.server_configs import server_configs
import requests
import urllib3
from django.conf import settings

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

server_configs = {
"dev": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": "http://sde-renaissance.nasa-impact.net",
},
"test": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": "https://sciencediscoveryengine.test.nasa.gov",
"index": "sde_index",
},
"production": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": "https://sciencediscoveryengine.nasa.gov",
"index": "sde_index",
},
"secret_test": {
"app_name": "nasa-sba-sde",
"query_name": "query-sde-primary",
"base_url": "https://sciencediscoveryengine.test.nasa.gov",
"index": "sde_index",
},
"secret_production": {
"app_name": "nasa-sba-sde",
"query_name": "query-sde-primary",
"base_url": "https://sciencediscoveryengine.nasa.gov",
"index": "sde_index",
},
"xli": {
"app_name": "nasa-sba-smd",
"query_name": "query-smd-primary",
"base_url": "http://sde-xli.nasa-impact.net",
"index": "sde_index",
},
"lrm_dev": {
"app_name": "sde-init-check",
"query_name": "query-init-check",
"base_url": "https://sde-lrm.nasa-impact.net",
"index": "sde_init_check",
},
"lrm_qa": {
"app_name": "sde-init-check",
"query_name": "query-init-check",
"base_url": "https://sde-qa.nasa-impact.net",
},
}


class Api:
def __init__(self, server_name: str = None, user: str = None, password: str = None, token: str = None) -> None:
self.server_name = server_name
Expand Down

0 comments on commit 6bc38d0

Please sign in to comment.