Skip to content

Commit c54b126

Browse files
authored
Merge pull request #974 from NASA-IMPACT/2429-implement-the-frontend-and-backend-for-url-based-division-picker
Division by URL feature
2 parents ec652e8 + 4573768 commit c54b126

File tree

70 files changed

+744
-401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+744
-401
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Navigate to the server running prod, then to the project folder. Run the followi
8484
```bash
8585
docker-compose -f production.yml run --rm --user root django python manage.py dumpdata --natural-foreign --natural-primary --exclude=contenttypes --exclude=auth.Permission --indent 2 --output /app/backups/prod_backup-20240812.json
8686
```
87-
This will have saved the backup in a folder outside of the docker container. Now you can copy it to your local machine.
87+
This will have saved the backup in a folder outside of the docker container. Now you can copy it to your local machine.
8888

8989
```bash
9090
mv ~/prod_backup-20240812.json <project_path>/prod_backup-20240812.json

config/settings/local.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
# EMAIL
2727
# ------------------------------------------------------------------------------
2828
# https://docs.djangoproject.com/en/dev/ref/settings/#email-backend
29-
EMAIL_BACKEND = env(
30-
"DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend"
31-
)
29+
EMAIL_BACKEND = env("DJANGO_EMAIL_BACKEND", default="django.core.mail.backends.console.EmailBackend")
3230

3331
# django-debug-toolbar
3432
# ------------------------------------------------------------------------------

config/settings/production.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
# https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
1414
SECRET_KEY = env("DJANGO_SECRET_KEY")
1515
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
16-
ALLOWED_HOSTS = env.list(
17-
"DJANGO_ALLOWED_HOSTS", default=["sde-indexing-helper.nasa-impact.net"]
18-
)
16+
ALLOWED_HOSTS = env.list("DJANGO_ALLOWED_HOSTS", default=["sde-indexing-helper.nasa-impact.net"])
1917

2018
# DATABASES
2119
# ------------------------------------------------------------------------------
@@ -36,15 +34,11 @@
3634
# TODO: set this to 60 seconds first and then to 518400 once you prove the former works
3735
SECURE_HSTS_SECONDS = 60
3836
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-include-subdomains
39-
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool(
40-
"DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", default=True
41-
)
37+
SECURE_HSTS_INCLUDE_SUBDOMAINS = env.bool("DJANGO_SECURE_HSTS_INCLUDE_SUBDOMAINS", default=True)
4238
# https://docs.djangoproject.com/en/dev/ref/settings/#secure-hsts-preload
4339
SECURE_HSTS_PRELOAD = env.bool("DJANGO_SECURE_HSTS_PRELOAD", default=True)
4440
# https://docs.djangoproject.com/en/dev/ref/middleware/#x-content-type-options-nosniff
45-
SECURE_CONTENT_TYPE_NOSNIFF = env.bool(
46-
"DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True
47-
)
41+
SECURE_CONTENT_TYPE_NOSNIFF = env.bool("DJANGO_SECURE_CONTENT_TYPE_NOSNIFF", default=True)
4842

4943
# STORAGES
5044
# ------------------------------------------------------------------------------
@@ -61,9 +55,7 @@
6155
# DO NOT change these unless you know what you're doing.
6256
_AWS_EXPIRY = 60 * 60 * 24 * 7
6357
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
64-
AWS_S3_OBJECT_PARAMETERS = {
65-
"CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate"
66-
}
58+
AWS_S3_OBJECT_PARAMETERS = {"CacheControl": f"max-age={_AWS_EXPIRY}, s-maxage={_AWS_EXPIRY}, must-revalidate"}
6759
# https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
6860
AWS_S3_MAX_MEMORY_SIZE = env.int(
6961
"DJANGO_AWS_S3_MAX_MEMORY_SIZE",
@@ -128,12 +120,7 @@
128120
LOGGING = {
129121
"version": 1,
130122
"disable_existing_loggers": True,
131-
"formatters": {
132-
"verbose": {
133-
"format": "%(levelname)s %(asctime)s %(module)s "
134-
"%(process)d %(thread)d %(message)s"
135-
}
136-
},
123+
"formatters": {"verbose": {"format": "%(levelname)s %(asctime)s %(module)s " "%(process)d %(thread)d %(message)s"}},
137124
"handlers": {
138125
"console": {
139126
"level": "DEBUG",

config/urls.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
from django.urls import include, path
55
from django.views import defaults as default_views
66

7-
admin.site.site_header = (
8-
"SDE Indexing Helper Administration" # default: "Django Administration"
9-
)
7+
admin.site.site_header = "SDE Indexing Helper Administration" # default: "Django Administration"
108
admin.site.index_title = "SDE Indexing Helper" # default: "Site administration"
119
admin.site.site_title = "SDE Indexing Helper" # default: "Django site admin"
1210

config_generation/api.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020

2121
class Api:
2222
def __init__(self, server_name: str) -> None:
23-
self.headers: dict[str, str] = {
24-
"Authorization": f"Bearer {tokens[server_name]}"
25-
}
23+
self.headers: dict[str, str] = {"Authorization": f"Bearer {tokens[server_name]}"}
2624
self.app_name: str = server_configs[server_name]["app_name"]
2725
self.query_name: str = server_configs[server_name]["query_name"]
2826
self.base_url: str = server_configs[server_name]["base_url"]
@@ -53,15 +51,11 @@ def query(self, term: str):
5351

5452
return self.process_response(url, payload)
5553

56-
def sql(
57-
self, source: str, collection: str = "", fetch_all: bool = False
58-
) -> dict[str, Any]:
54+
def sql(self, source: str, collection: str = "", fetch_all: bool = False) -> dict[str, Any]:
5955
url = f"{self.base_url}/api/v1/engine.sql"
6056

6157
collection_name = f"/{source}/{collection}/"
62-
sql_command_all = (
63-
"select url1,title,collection from @@ScienceMissionDirectorate"
64-
)
58+
sql_command_all = "select url1,title,collection from @@ScienceMissionDirectorate"
6559
if fetch_all:
6660
sql_command = sql_command_all
6761
else:

config_generation/config_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from sources_to_scrape import (
2-
sources_to_index_test_grid_20240809,
3-
)
1+
from sources_to_scrape import sources_to_index_test_grid_20240809
42

53
tokens: dict[str, str] = {
64
"test_server": "token here",

config_generation/delete_server_content.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
from db_to_xml_file_based import XmlEditor
44

5-
from config import batch_delete_name, collection_list, indexes_to_delete_from, source, engines
5+
from config import (
6+
batch_delete_name,
7+
collection_list,
8+
engines,
9+
indexes_to_delete_from,
10+
source,
11+
)
612

713
COMMAND_FILES_PATH = "../sinequa_configs/commands/"
814
DELETE_COMMAND_TEMPLATE_PATH = "xmls/delete_template.xml"

config_generation/export_collections.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,13 @@
4444
# Create JSON file
4545
print("Creating JSON dump...")
4646
json_data = json.dumps(bulk_data)
47-
file_path = (
48-
f"{TEMP_FOLDER_NAME}/{collection}/urls.json" # Provide the desired file path
49-
)
47+
file_path = f"{TEMP_FOLDER_NAME}/{collection}/urls.json" # Provide the desired file path
5048
with open(file_path, "w") as file:
5149
file.write(json_data)
5250

5351
# Zip the JSON file
5452
print("Creating zip file...")
55-
zip_file_path = (
56-
f"{TEMP_FOLDER_NAME}/{collection}.zip" # Provide the desired zip file path
57-
)
53+
zip_file_path = f"{TEMP_FOLDER_NAME}/{collection}.zip" # Provide the desired zip file path
5854
with zipfile.ZipFile(zip_file_path, "w") as zip_file:
5955
zip_file.write(file_path, os.path.basename(file_path))
6056

config_generation/export_whole_index.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@
4444

4545
# Upload the zip file to S3
4646
s3_bucket_name = env("DJANGO_AWS_STORAGE_BUCKET_NAME")
47-
s3_key = (
48-
"scraped_urls_all/all_data.zip" # Provide the desired S3 key for the uploaded file
49-
)
47+
s3_key = "scraped_urls_all/all_data.zip" # Provide the desired S3 key for the uploaded file
5048
s3_client = boto3.client(
5149
"s3",
5250
region_name="us-east-1",

config_generation/generate_collection_list.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ def create_xml_path(collection_name):
2222

2323
def get_turned_on_sources():
2424
# remove sources that were just scraped
25-
turned_on_remaining_sources = [
26-
source for source in turned_on_sources if source not in already_scraped_sources
27-
]
25+
turned_on_remaining_sources = [source for source in turned_on_sources if source not in already_scraped_sources]
2826

2927
# filter all sources to only webcrawler sources
3028
turned_on_remaining_webcrawlers = []
@@ -68,8 +66,5 @@ def get_sources_20230605():
6866
folders = get_all_config_folder_names()
6967
folders = folders + interrupted_sources
7068
return [
71-
folder
72-
for folder in folders
73-
if folder not in sources_with_documents_20230605
74-
and is_collection_crawler(folder)
69+
folder for folder in folders if folder not in sources_with_documents_20230605 and is_collection_crawler(folder)
7570
]

0 commit comments

Comments
 (0)