Skip to content

Commit

Permalink
HARMONY-1909: Updated all notebooks with the new helper import function.
Browse files Browse the repository at this point in the history
  • Loading branch information
ygliuvt committed Oct 16, 2024
1 parent 04b1b7a commit 06fdd59
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 74 deletions.
19 changes: 4 additions & 15 deletions examples/basic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,10 @@
"outputs": [],
"source": [
"# Install notebook requirements\n",
"import sys; sys.path.append('..')\n",
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "knowing-atlas",
"metadata": {},
"outputs": [],
"source": [
"import helper"
"import sys\n",
"import helper\n",
"# Install the project and 'examples' dependencies\n",
"helper.install_project_and_dependencies('..', libs=['examples'])"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion examples/collection_capabilities.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"sys.path.append('..')\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
"helper.install_project_and_dependencies('..')\n",
"\n",
"from harmony import BBox, Client, Collection, Request, CapabilitiesRequest, Environment"
]
Expand Down
11 changes: 11 additions & 0 deletions examples/helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import sys
import os
sys.path.append('..')

import datetime as dt
from getpass import getpass
from glob import glob
from time import sleep

import ipyplot
from ipywidgets import IntSlider, Password, Text
from IPython.display import display, JSON
import rasterio
from rasterio.plot import show
import requests

def install_project_and_dependencies(project_root, libs=None):
"""
Expand Down
9 changes: 4 additions & 5 deletions examples/intro_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@
"outputs": [],
"source": [
"# Install notebook requirements\n",
"import sys; sys.path.append('..')\n",
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel\n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt"
"import sys\n",
"import helper\n",
"# Install the project and 'examples' dependencies\n",
"helper.install_project_and_dependencies('..', libs=['examples'])"
]
},
{
Expand Down
6 changes: 2 additions & 4 deletions examples/job_pause_resume.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
"outputs": [],
"source": [
"import sys\n",
"sys.path.append('..')\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
"import helper\n",
"helper.install_project_and_dependencies('..')\n",
"\n",
"from harmony import BBox, Client, Collection, Request, Environment"
]
Expand Down
13 changes: 2 additions & 11 deletions examples/job_results.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
"outputs": [],
"source": [
"import sys\n",
"sys.path.append('..')\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
"import helper\n",
"helper.install_project_and_dependencies('..')\n",
"\n",
"from harmony import BBox, Client, Collection, Request, Environment\n"
]
Expand Down Expand Up @@ -123,13 +121,6 @@
"# Blocking upon calling result()\n",
"file_name = harmony_client.download(next(urls), overwrite=True).result()\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
6 changes: 2 additions & 4 deletions examples/job_results_iterator.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
"outputs": [],
"source": [
"import sys\n",
"sys.path.append('..')\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
"import helper\n",
"helper.install_project_and_dependencies('..')\n",
"\n",
"import concurrent.futures\n",
"import os\n",
Expand Down
9 changes: 3 additions & 6 deletions examples/job_stac.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
"outputs": [],
"source": [
"import sys\n",
"sys.path.append('..')\n",
"\n",
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
"import helper\n",
"# Install the project and 'examples' dependencies\n",
"helper.install_project_and_dependencies('..', libs=['examples'])\n",
"\n",
"from harmony import BBox, Client, Collection, Request, Environment"
]
Expand Down
6 changes: 2 additions & 4 deletions examples/job_status.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
"outputs": [],
"source": [
"import sys\n",
"sys.path.append('..')\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
"import helper\n",
"helper.install_project_and_dependencies('..')\n",
"\n",
"from harmony import BBox, Client, Collection, Request, Environment"
]
Expand Down
16 changes: 7 additions & 9 deletions examples/s3_access.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@
"source": [
"import datetime as dt\n",
"import sys\n",
"sys.path.append('..')\n",
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
"import helper\n",
"# Install the project and 'examples' dependencies\n",
"helper.install_project_and_dependencies('..', libs=['examples'])\n",
"\n",
"from harmony import BBox, Client, Collection, LinkType, Request, s3_components, Environment"
]
Expand All @@ -45,7 +43,7 @@
" height=512,\n",
" width=512,\n",
" # If desired, deliver results to a custom destination bucket. Note the bucket must reside in AWS us-west-2 region.\n",
" # destination_url='s3://my-bucket' \n",
" # destination_url='s3://my-bucket'\n",
")\n",
"\n",
"request.is_valid()"
Expand Down Expand Up @@ -102,7 +100,7 @@
"outputs": [],
"source": [
"#\n",
"# NOTE: Execution of this cell will only succeed within the AWS us-west-2 region. \n",
"# NOTE: Execution of this cell will only succeed within the AWS us-west-2 region.\n",
"#\n",
"\n",
"import boto3\n",
Expand All @@ -117,7 +115,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -131,7 +129,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.2"
"version": "3.11.9"
},
"vscode": {
"interpreter": {
Expand Down
19 changes: 4 additions & 15 deletions examples/shapefile_subset.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
"outputs": [],
"source": [
"import sys\n",
"sys.path.append('..')\n",
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
"\n",
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
"import helper\n",
"# Install the project and 'examples' dependencies\n",
"helper.install_project_and_dependencies('..', libs=['examples'])\n",
"\n",
"import datetime as dt\n",
"\n",
"from harmony import BBox, Client, Collection, Request\n",
"from harmony.config import Environment\n",
"\n",
Expand Down Expand Up @@ -102,17 +99,9 @@
"metadata": {},
"outputs": [],
"source": [
"import helper\n",
"for filename in [f.result() for f in harmony_client.download_all(job_id)]:\n",
" helper.show_result(filename)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -131,7 +120,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.11.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 06fdd59

Please sign in to comment.