Skip to content

Commit 06fdd59

Browse files
committed
HARMONY-1909: Updated all notebooks with the new helper import function.
1 parent 04b1b7a commit 06fdd59

11 files changed

+42
-74
lines changed

examples/basic.ipynb

+4-15
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,10 @@
2222
"outputs": [],
2323
"source": [
2424
"# Install notebook requirements\n",
25-
"import sys; sys.path.append('..')\n",
26-
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
27-
"\n",
28-
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
29-
"!{sys.executable} -m pip install -q -r ../requirements/core.txt"
30-
]
31-
},
32-
{
33-
"cell_type": "code",
34-
"execution_count": null,
35-
"id": "knowing-atlas",
36-
"metadata": {},
37-
"outputs": [],
38-
"source": [
39-
"import helper"
25+
"import sys\n",
26+
"import helper\n",
27+
"# Install the project and 'examples' dependencies\n",
28+
"helper.install_project_and_dependencies('..', libs=['examples'])"
4029
]
4130
},
4231
{

examples/collection_capabilities.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"sys.path.append('..')\n",
2323
"\n",
2424
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
25-
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
25+
"helper.install_project_and_dependencies('..')\n",
2626
"\n",
2727
"from harmony import BBox, Client, Collection, Request, CapabilitiesRequest, Environment"
2828
]

examples/helper.py

+11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
import sys
22
import os
3+
sys.path.append('..')
4+
5+
import datetime as dt
6+
from getpass import getpass
7+
from glob import glob
8+
from time import sleep
9+
10+
import ipyplot
11+
from ipywidgets import IntSlider, Password, Text
12+
from IPython.display import display, JSON
313
import rasterio
414
from rasterio.plot import show
15+
import requests
516

617
def install_project_and_dependencies(project_root, libs=None):
718
"""

examples/intro_tutorial.ipynb

+4-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,10 @@
3636
"outputs": [],
3737
"source": [
3838
"# Install notebook requirements\n",
39-
"import sys; sys.path.append('..')\n",
40-
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
41-
"\n",
42-
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel\n",
43-
"!{sys.executable} -m pip install -q -r ../requirements/core.txt"
39+
"import sys\n",
40+
"import helper\n",
41+
"# Install the project and 'examples' dependencies\n",
42+
"helper.install_project_and_dependencies('..', libs=['examples'])"
4443
]
4544
},
4645
{

examples/job_pause_resume.ipynb

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
"outputs": [],
1616
"source": [
1717
"import sys\n",
18-
"sys.path.append('..')\n",
19-
"\n",
20-
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
21-
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
18+
"import helper\n",
19+
"helper.install_project_and_dependencies('..')\n",
2220
"\n",
2321
"from harmony import BBox, Client, Collection, Request, Environment"
2422
]

examples/job_results.ipynb

+2-11
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
"outputs": [],
1616
"source": [
1717
"import sys\n",
18-
"sys.path.append('..')\n",
19-
"\n",
20-
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
21-
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
18+
"import helper\n",
19+
"helper.install_project_and_dependencies('..')\n",
2220
"\n",
2321
"from harmony import BBox, Client, Collection, Request, Environment\n"
2422
]
@@ -123,13 +121,6 @@
123121
"# Blocking upon calling result()\n",
124122
"file_name = harmony_client.download(next(urls), overwrite=True).result()\n"
125123
]
126-
},
127-
{
128-
"cell_type": "code",
129-
"execution_count": null,
130-
"metadata": {},
131-
"outputs": [],
132-
"source": []
133124
}
134125
],
135126
"metadata": {

examples/job_results_iterator.ipynb

+2-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@
1515
"outputs": [],
1616
"source": [
1717
"import sys\n",
18-
"sys.path.append('..')\n",
19-
"\n",
20-
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
21-
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
18+
"import helper\n",
19+
"helper.install_project_and_dependencies('..')\n",
2220
"\n",
2321
"import concurrent.futures\n",
2422
"import os\n",

examples/job_stac.ipynb

+3-6
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
"outputs": [],
1616
"source": [
1717
"import sys\n",
18-
"sys.path.append('..')\n",
19-
"\n",
20-
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
21-
"\n",
22-
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
23-
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
18+
"import helper\n",
19+
"# Install the project and 'examples' dependencies\n",
20+
"helper.install_project_and_dependencies('..', libs=['examples'])\n",
2421
"\n",
2522
"from harmony import BBox, Client, Collection, Request, Environment"
2623
]

examples/job_status.ipynb

+2-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717
"outputs": [],
1818
"source": [
1919
"import sys\n",
20-
"sys.path.append('..')\n",
21-
"\n",
22-
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
23-
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
20+
"import helper\n",
21+
"helper.install_project_and_dependencies('..')\n",
2422
"\n",
2523
"from harmony import BBox, Client, Collection, Request, Environment"
2624
]

examples/s3_access.ipynb

+7-9
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
"source": [
1717
"import datetime as dt\n",
1818
"import sys\n",
19-
"sys.path.append('..')\n",
20-
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
21-
"\n",
22-
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
23-
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
19+
"import helper\n",
20+
"# Install the project and 'examples' dependencies\n",
21+
"helper.install_project_and_dependencies('..', libs=['examples'])\n",
2422
"\n",
2523
"from harmony import BBox, Client, Collection, LinkType, Request, s3_components, Environment"
2624
]
@@ -45,7 +43,7 @@
4543
" height=512,\n",
4644
" width=512,\n",
4745
" # If desired, deliver results to a custom destination bucket. Note the bucket must reside in AWS us-west-2 region.\n",
48-
" # destination_url='s3://my-bucket' \n",
46+
" # destination_url='s3://my-bucket'\n",
4947
")\n",
5048
"\n",
5149
"request.is_valid()"
@@ -102,7 +100,7 @@
102100
"outputs": [],
103101
"source": [
104102
"#\n",
105-
"# NOTE: Execution of this cell will only succeed within the AWS us-west-2 region. \n",
103+
"# NOTE: Execution of this cell will only succeed within the AWS us-west-2 region.\n",
106104
"#\n",
107105
"\n",
108106
"import boto3\n",
@@ -117,7 +115,7 @@
117115
],
118116
"metadata": {
119117
"kernelspec": {
120-
"display_name": "venv",
118+
"display_name": "Python 3 (ipykernel)",
121119
"language": "python",
122120
"name": "python3"
123121
},
@@ -131,7 +129,7 @@
131129
"name": "python",
132130
"nbconvert_exporter": "python",
133131
"pygments_lexer": "ipython3",
134-
"version": "3.9.2"
132+
"version": "3.11.9"
135133
},
136134
"vscode": {
137135
"interpreter": {

examples/shapefile_subset.ipynb

+4-15
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@
2222
"outputs": [],
2323
"source": [
2424
"import sys\n",
25-
"sys.path.append('..')\n",
26-
"!{sys.executable} -m pip install -q -r ../requirements/examples.txt\n",
27-
"\n",
28-
"# Install harmony-py requirements. Not necessary if you ran `pip install harmony-py` in your kernel \n",
29-
"!{sys.executable} -m pip install -q -r ../requirements/core.txt\n",
25+
"import helper\n",
26+
"# Install the project and 'examples' dependencies\n",
27+
"helper.install_project_and_dependencies('..', libs=['examples'])\n",
3028
"\n",
3129
"import datetime as dt\n",
32-
"\n",
3330
"from harmony import BBox, Client, Collection, Request\n",
3431
"from harmony.config import Environment\n",
3532
"\n",
@@ -102,17 +99,9 @@
10299
"metadata": {},
103100
"outputs": [],
104101
"source": [
105-
"import helper\n",
106102
"for filename in [f.result() for f in harmony_client.download_all(job_id)]:\n",
107103
" helper.show_result(filename)"
108104
]
109-
},
110-
{
111-
"cell_type": "code",
112-
"execution_count": null,
113-
"metadata": {},
114-
"outputs": [],
115-
"source": []
116105
}
117106
],
118107
"metadata": {
@@ -131,7 +120,7 @@
131120
"name": "python",
132121
"nbconvert_exporter": "python",
133122
"pygments_lexer": "ipython3",
134-
"version": "3.8.2"
123+
"version": "3.11.9"
135124
}
136125
},
137126
"nbformat": 4,

0 commit comments

Comments
 (0)