Skip to content

Commit

Permalink
Generalize notebook to work for any user
Browse files Browse the repository at this point in the history
Refs #995
  • Loading branch information
shawncrawley committed Dec 16, 2024
1 parent 971a814 commit 9d5afb7
Showing 1 changed file with 7 additions and 48 deletions.
55 changes: 7 additions & 48 deletions Core/Manual_Workflows/Align MAPX dtypes with DB.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "22943b62-1ee7-408d-95f7-b628d4ff07cc",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import os\n",
"with open('../Secrets.env') as f:\n",
"with open('/home/ec2-user/SageMaker/Secrets.env') as f:\n",
" for l in f.readlines():\n",
" if l.strip():\n",
" var, val = l.strip().split(\"=\", 1)\n",
Expand All @@ -19,41 +19,12 @@
},
{
"cell_type": "code",
"execution_count": 20,
"execution_count": null,
"id": "fe247ea4-86b6-48bb-be4b-ffca3fdb2f20",
"metadata": {
"tags": []
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"static_stage_based_catfim.mapx :: \"Stage-Based CatFIM Sites\" :: reference.stage_based_catfim_sites_public does not exist.\n",
"hydrovis.reference.stage_based_catfim_sites_public\n",
"static_stage_based_catfim.mapx :: \"1 ft Invervals Above Action\" :: reference.stage_based_catfim_public does not exist.\n",
"hydrovis.reference.stage_based_catfim_public\n",
"static_stage_based_catfim.mapx :: \"Stage-Based CatFIM: Action Threshold\" :: reference.stage_based_catfim_public does not exist.\n",
"hydrovis.reference.stage_based_catfim_public\n",
"static_stage_based_catfim.mapx :: \"1 ft Invervals Above Minor\" :: reference.stage_based_catfim_public does not exist.\n",
"hydrovis.reference.stage_based_catfim_public\n",
"static_stage_based_catfim.mapx :: \"Stage-Based CatFIM: Minor Threshold\" :: reference.stage_based_catfim_public does not exist.\n",
"hydrovis.reference.stage_based_catfim_public\n",
"static_stage_based_catfim.mapx :: \"1 ft Invervals Above Moderate\" :: reference.stage_based_catfim_public does not exist.\n",
"hydrovis.reference.stage_based_catfim_public\n",
"static_stage_based_catfim.mapx :: \"Stage-Based CatFIM: Moderate Threshold\" :: reference.stage_based_catfim_public does not exist.\n",
"hydrovis.reference.stage_based_catfim_public\n",
"static_stage_based_catfim.mapx :: \"1 ft Invervals Above Major\" :: reference.stage_based_catfim_public does not exist.\n",
"hydrovis.reference.stage_based_catfim_public\n",
"static_stage_based_catfim.mapx :: \"Stage-Based CatFIM: Major Threshold\" :: reference.stage_based_catfim_public does not exist.\n",
"hydrovis.reference.stage_based_catfim_public\n",
"static_stage_based_catfim.mapx :: \"Stage-Based CatFIM: Record Threshold\" :: reference.stage_based_catfim_public does not exist.\n",
"hydrovis.reference.stage_based_catfim_public\n",
"static_hand_catchments_0_branches_prvi_noaa.mapx :: \"Branch 0 FIM Catchment Boundaries\" :: fim_catchments.catchments_0_braches_prvi does not exist.\n",
"hydrovis.fim_catchments.catchments_0_braches_prvi\n"
]
}
],
"outputs": [],
"source": [
"from requests import Session\n",
"from pathlib import Path\n",
Expand All @@ -62,7 +33,7 @@
"import os\n",
"\n",
"THIS_DIR = Path.cwd()\n",
"CORE_DIR = THIS_DIR / \"hydrovis\" / \"Core\"\n",
"CORE_DIR = THIS_DIR.parent\n",
"SERVICES_DIR = CORE_DIR / \"LAMBDA\" / \"viz_functions\" / \"viz_publish_service\" / \"services\"\n",
"\n",
"ESRI_TYPE_TO_DB_TYPES = {\n",
Expand All @@ -86,6 +57,8 @@
"\n",
"server_services = []\n",
"for root, dirs, files in os.walk(SERVICES_DIR):\n",
" print(\"COOL\")\n",
" continue\n",
" for fname in files:\n",
" if fname.endswith('.mapx'):\n",
" fpath = Path(root) / fname\n",
Expand Down Expand Up @@ -170,20 +143,6 @@
" fpath.write_text(json.dumps(mapx, separators=(',', ' : '), indent=2))\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "17cea5a6-4275-47a4-ad56-48a98ba41a0a",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from shared_functions import sql_to_dataframe\n",
"\n",
"sql_to_dataframe(\"SELECT DISTINCT nwm_features_flooded_percent FROM services.mrf_gfs_10day_rapid_onset_flooding_hucs_alaska\", db_type=\"egis\")"
]
}
],
"metadata": {
Expand Down

0 comments on commit 9d5afb7

Please sign in to comment.