Skip to content

Commit 26a866f

Browse files
Merge pull request #360 from ASFHyP3/update-sdk-nb
Point SDK notebook users to Authentication notebook
2 parents f4cfe8c + 205b5ac commit 26a866f

File tree

5 files changed

+107
-62
lines changed

5 files changed

+107
-62
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
77
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [7.7.1]
10+
11+
### Changed
12+
* [SDK example notebook](https://github.com/ASFHyP3/hyp3-sdk/blob/main/docs/sdk_example.ipynb) now references the [HyP3 authentication notebook](https://github.com/ASFHyP3/hyp3-sdk/blob/main/docs/hyp3_authentication.ipynb) in the authentication section.
13+
* The [hyp3-docs authentication documentation page](https://hyp3-docs.asf.alaska.edu/using/authentication/) is linked in the [HyP3 authentication notebook](https://github.com/ASFHyP3/hyp3-sdk/blob/main/docs/hyp3_authentication.ipynb).
14+
915
## [7.7.0]
1016

1117
### Added

docs/hyp3_authentication.ipynb

Lines changed: 85 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,36 @@
99
"source": [
1010
"# Authenticating a HyP3 Session with the SDK\n",
1111
"\n",
12-
"When initializing a HyP3 object with the HyP3 SDK, you have three options:\n",
12+
"To access most HyP3 functions, you must authenticate using\n",
13+
"[Earthdata Login (EDL)](https://urs.earthdata.nasa.gov/) credentials.\n",
14+
"\n",
15+
"When initializing a HyP3 object with the HyP3 SDK, you have three authentication options:\n",
1316
"1. Input your EDL username and password\n",
1417
"2. Input your EDL Bearer Token\n",
1518
"3. Store your credentials locally in a .netrc file in your home directory\n",
1619
"\n",
17-
"This tutorial will walk you through each of these authentication methods. If you have not created an Earthdata Login account yet, make sure to do so here: https://urs.earthdata.nasa.gov/users/new.\n",
20+
"This tutorial will walk you through each of these authentication methods. You can also refer to our\n",
21+
"[authentication documentation](https://hyp3-docs.asf.alaska.edu/using/authentication/) to learn more about HyP3 authentication.\n",
22+
"\n",
23+
"If you have not created an Earthdata Login account yet, you can do so here:\n",
24+
"[https://urs.earthdata.nasa.gov/users/new](https://urs.earthdata.nasa.gov/users/new)"
25+
]
26+
},
27+
{
28+
"cell_type": "markdown",
29+
"id": "9a6d6beb7a378045",
30+
"metadata": {
31+
"collapsed": false
32+
},
33+
"source": [
34+
"## Installing hyp3-sdk\n",
35+
"\n",
36+
"Before working through this notebook, make sure you have the `hyp3-sdk` Python package installed locally and\n",
37+
"ensure the version is >=7.7.0.\n",
1838
"\n",
19-
"Likewise, before starting, make sure you have `hyp3-sdk` installed locally and ensure the version is >=7.7.0."
39+
"If `hyp3-sdk` is not installed, you can run the next code cell to pip install it.\n",
40+
"Refer to the [SDK Example notebook](https://github.com/ASFHyP3/hyp3-sdk/blob/main/docs/sdk_example.ipynb)\n",
41+
"for more information on installation options."
2042
]
2143
},
2244
{
@@ -32,16 +54,26 @@
3254
]
3355
},
3456
{
35-
"cell_type": "code",
36-
"execution_count": null,
37-
"outputs": [],
57+
"cell_type": "markdown",
3858
"source": [
39-
"import hyp3_sdk as sdk"
59+
"Import the `hyp3_sdk` module."
4060
],
4161
"metadata": {
4262
"collapsed": false
4363
},
44-
"id": "a38df62d8552468b"
64+
"id": "eb39ae640277c6d3"
65+
},
66+
{
67+
"cell_type": "code",
68+
"execution_count": null,
69+
"id": "a38df62d8552468b",
70+
"metadata": {
71+
"collapsed": false
72+
},
73+
"outputs": [],
74+
"source": [
75+
"import hyp3_sdk as sdk"
76+
]
4577
},
4678
{
4779
"cell_type": "markdown",
@@ -50,8 +82,11 @@
5082
"collapsed": false
5183
},
5284
"source": [
53-
"## Using your username and password\n",
54-
"This option requires minimal amount of set up. All you need is to know your EDL username and password. You can either prompt for a username and password by passing `password` in as `prompt`:"
85+
"## Using your EDL Username and Password\n",
86+
"This option requires minimal set up. All you need is to know your\n",
87+
"[EDL username and password](https://hyp3-docs.asf.alaska.edu/using/authentication/#username-and-password). \n",
88+
"\n",
89+
"You can either prompt for a username and password by passing `password` in as `prompt`:"
5590
]
5691
},
5792
{
@@ -63,7 +98,7 @@
6398
},
6499
"outputs": [],
65100
"source": [
66-
"HyP3 = sdk.HyP3(prompt='password')"
101+
"hyp3 = sdk.HyP3(prompt='password')"
67102
]
68103
},
69104
{
@@ -73,7 +108,7 @@
73108
"collapsed": false
74109
},
75110
"source": [
76-
"Or pass them directly:"
111+
"or pass them directly:"
77112
]
78113
},
79114
{
@@ -88,7 +123,7 @@
88123
"username = 'myusername'\n",
89124
"password = 'mypassword'\n",
90125
"\n",
91-
"HyP3 = sdk.HyP3(username=username, password=password)"
126+
"hyp3 = sdk.HyP3(username=username, password=password)"
92127
]
93128
},
94129
{
@@ -98,33 +133,33 @@
98133
"collapsed": false
99134
},
100135
"source": [
101-
"## Using your EDL Bearer Token\n",
102-
"Alternatively, you can authenticate your HyP3 object using your EDL token. Follow this documentation to create one: https://urs.earthdata.nasa.gov/documentation/for_users/user_token.\n",
136+
"## Using an EDL Bearer Token\n",
137+
"Alternatively, you can authenticate your HyP3 object using an EDL token. Follow this documentation to create one: [https://urs.earthdata.nasa.gov/documentation/for_users/user_token](https://urs.earthdata.nasa.gov/documentation/for_users/user_token)\n",
103138
"\n",
104-
"Once that token is set up, prompt for an EDL token:"
139+
"Once you have an EDL token, you can prompt for it by passing `token` in as `prompt`:"
105140
]
106141
},
107142
{
108143
"cell_type": "code",
109144
"execution_count": null,
110-
"outputs": [],
111-
"source": [
112-
"HyP3 = sdk.HyP3(prompt='token')"
113-
],
145+
"id": "7805f87763471220",
114146
"metadata": {
115147
"collapsed": false
116148
},
117-
"id": "7805f87763471220"
149+
"outputs": [],
150+
"source": [
151+
"hyp3 = sdk.HyP3(prompt='token')"
152+
]
118153
},
119154
{
120155
"cell_type": "markdown",
121-
"source": [
122-
"Or pass it directly:"
123-
],
156+
"id": "19f255f3f2c1a7c4",
124157
"metadata": {
125158
"collapsed": false
126159
},
127-
"id": "19f255f3f2c1a7c4"
160+
"source": [
161+
"or pass it directly:"
162+
]
128163
},
129164
{
130165
"cell_type": "code",
@@ -136,7 +171,7 @@
136171
"outputs": [],
137172
"source": [
138173
"token = 'mytoken'\n",
139-
"HyP3 = sdk.HyP3(token=token)"
174+
"hyp3 = sdk.HyP3(token=token)"
140175
]
141176
},
142177
{
@@ -146,12 +181,26 @@
146181
"collapsed": false
147182
},
148183
"source": [
149-
"## Using a local .netrc file\n",
150-
"This option take a bit more effort to set up but saves time in the long run. You will create a .netrc file in your local home directory. \n",
151-
"\n",
152-
"You can do this by running the following commands, replacing `USER` and `PASSWORD` with your EDL username and password:"
184+
"## Using a Local .netrc File\n",
185+
"This option takes a bit more effort to set up, but saves time in the long run.\n",
186+
"By adding your credentials to the .netrc file saved in your local home directory, they can be pulled automatically\n",
187+
"when initializing the HyP3 object with the HyP3 SDK."
153188
]
154189
},
190+
{
191+
"cell_type": "markdown",
192+
"source": [
193+
"You can add your credentials to a .netrc file programmatically.\n",
194+
"This approach first looks for an existing .netrc file and appends the credentials to it.\n",
195+
"If you don't already have a .netrc file, it will add one to your local home directory.\n",
196+
"\n",
197+
"Run the code cell below, replacing `USER` and `PASSWORD` with your EDL username and password:"
198+
],
199+
"metadata": {
200+
"collapsed": false
201+
},
202+
"id": "2b778c7c7c48074e"
203+
},
155204
{
156205
"cell_type": "code",
157206
"execution_count": null,
@@ -173,7 +222,7 @@
173222
"collapsed": false
174223
},
175224
"source": [
176-
"Now, when you initialize the HyP3 object, your credentials will be pulled from the .netrc file:"
225+
"Once the .netrc includes your credentials, you can initialize the HyP3 object without passing any arguments:"
177226
]
178227
},
179228
{
@@ -185,27 +234,27 @@
185234
},
186235
"outputs": [],
187236
"source": [
188-
"HyP3 = sdk.HyP3()"
237+
"hyp3 = sdk.HyP3()"
189238
]
190239
}
191240
],
192241
"metadata": {
193242
"kernelspec": {
194-
"display_name": "Python 3",
243+
"display_name": "Python 3 (ipykernel)",
195244
"language": "python",
196245
"name": "python3"
197246
},
198247
"language_info": {
199248
"codemirror_mode": {
200249
"name": "ipython",
201-
"version": 2
250+
"version": 3
202251
},
203252
"file_extension": ".py",
204253
"mimetype": "text/x-python",
205254
"name": "python",
206255
"nbconvert_exporter": "python",
207-
"pygments_lexer": "ipython2",
208-
"version": "2.7.6"
256+
"pygments_lexer": "ipython3",
257+
"version": "3.11.13"
209258
}
210259
},
211260
"nbformat": 4,

docs/hyp3_job_name_change.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
},
4646
"outputs": [],
4747
"source": [
48-
"hyp3 = sdk.HyP3(prompt='token')\n",
48+
"hyp3 = sdk.HyP3(prompt='password')\n",
4949
"\n",
5050
"project_name = 'renameDemo'\n",
5151
"reference = 'S1_136231_IW2_20200604T022312_VV_7C85-BURST'\n",

docs/sdk_example.ipynb

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
"HyP3's Python SDK `hyp3_sdk` provides a convenience wrapper around the HyP3 API and HyP3 jobs.\n",
1414
"\n",
1515
"\n",
16-
"The HyP3 SDK can be installed using [Anaconda/Miniconda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html#anaconda-or-miniconda)\n",
17-
" (recommended) via [`conda`](https://anaconda.org/conda-forge/hyp3_sdk):\n",
16+
"The HyP3 SDK can be installed using [Anaconda/Miniconda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html#anaconda-or-miniconda) (recommended) via [`conda`](https://anaconda.org/conda-forge/hyp3_sdk):\n",
1817
"\n",
1918
"```\n",
2019
"conda install -c conda-forge hyp3_sdk\n",
@@ -30,8 +29,9 @@
3029
"\n",
3130
"### Other recommended packages\n",
3231
"\n",
33-
"We also recommend installing the `asf_search` Python package for performing searches of the ASF catalog. The ASF Search\n",
34-
"Python package can be installed using [Anaconda/Miniconda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html#anaconda-or-miniconda)\n",
32+
"We also recommend installing the `asf_search` Python package for performing searches of the ASF catalog.\n",
33+
"The ASF Search Python package can be installed using\n",
34+
"[Anaconda/Miniconda](https://docs.conda.io/projects/conda/en/latest/user-guide/install/download.html#anaconda-or-miniconda)\n",
3535
"(recommended) via [`conda`](https://anaconda.org/conda-forge/asf_search):\n",
3636
"\n",
3737
"```\n",
@@ -65,8 +65,8 @@
6565
"source": [
6666
"## Authenticating to the API\n",
6767
"\n",
68-
"The SDK will attempt to pull your [NASA Earthdata Login](https://urs.earthdata.nasa.gov/) credentials out of `~/.netrc`\n",
69-
"by default, or you can pass your credentials in directly"
68+
"There are several approaches available for authenticating the HyP3 API in the SDK. Refer to our [HyP3 Authentication notebook](https://github.com/ASFHyP3/hyp3-sdk/blob/main/docs/hyp3_authentication.ipynb) for more information and sample code for the different options. \n",
69+
"One option is to pass your credentials directly with the following code:"
7070
]
7171
},
7272
{
@@ -75,18 +75,8 @@
7575
"metadata": {},
7676
"outputs": [],
7777
"source": [
78-
"# .netrc\n",
79-
"hyp3 = sdk.HyP3()"
80-
]
81-
},
82-
{
83-
"cell_type": "code",
84-
"execution_count": null,
85-
"metadata": {},
86-
"outputs": [],
87-
"source": [
88-
"# or enter your credentials\n",
89-
"hyp3 = sdk.HyP3(prompt='token')"
78+
"# prompt for your EDL username and password\n",
79+
"hyp3 = sdk.HyP3(prompt='password')"
9080
]
9181
},
9282
{
@@ -99,7 +89,7 @@
9989
"\n",
10090
"### Submitting Sentinel-1 RTC jobs\n",
10191
"\n",
102-
"Sentinel-1 Radiometric Terrain Correction (RTC) jobs are submitted using [ESA granule IDs](https://sentinel.esa.int/web/sentinel/user-guides/sentinel-1-sar/naming-conventions).\n",
92+
"Sentinel-1 Radiometric Terrain Correction (RTC) jobs are submitted using [ESA granule IDs](https://sentiwiki.copernicus.eu/web/s1-products#S1Products-SARNamingConventionS1-Products-SAR-Naming-Convention).\n",
10393
"The example granules below can be viewed in [ASF Search here](https://search.asf.alaska.edu/#/?zoom=7.08772014623877&center=-141.733866,58.498008&resultsLoaded=true&granule=S1A_IW_SLC__1SDV_20210214T154835_20210214T154901_036588_044C54_8494-SLC&searchType=List%20Search&searchList=S1A_IW_SLC__1SDV_20210214T154835_20210214T154901_036588_044C54_8494-SLC,S1B_IW_SLC__1SDV_20210210T153131_20210210T153159_025546_030B48_B568-SLC,S1A_IW_SLC__1SDV_20210210T025526_20210210T025553_036522_0449E2_7769-SLC,S1A_IW_SLC__1SDV_20210210T025501_20210210T025528_036522_0449E2_3917-SLC,S1B_IW_SLC__1SDV_20210209T030255_20210209T030323_025524_030A8D_7E88-SLC,S1B_IW_SLC__1SDV_20210209T030227_20210209T030257_025524_030A8D_5BAF-SLC,S1A_IW_SLC__1SDV_20210202T154835_20210202T154902_036413_044634_01A1-SLC)."
10494
]
10595
},
@@ -222,8 +212,8 @@
222212
"### Submitting autoRIFT jobs\n",
223213
"\n",
224214
"AutoRIFT supports processing Sentinel-1, Sentinel-2, or Landsat-8 Collection 2 pairs.\n",
225-
"* Sentinel-1 jobs are submitted using [ESA granule IDs](https://sentinel.esa.int/web/sentinel/user-guides/sentinel-1-sar/naming-conventions)\n",
226-
"* Sentinel-2 jobs are submitted using [ESA granule IDs](https://sentinel.esa.int/web/sentinel/user-guides/sentinel-2-msi/naming-convention)\n",
215+
"* Sentinel-1 jobs are submitted using [ESA granule IDs](https://sentiwiki.copernicus.eu/web/s1-products#S1Products-SARNamingConventionS1-Products-SAR-Naming-Convention)\n",
216+
"* Sentinel-2 jobs are submitted using [ESA granule IDs](https://sentiwiki.copernicus.eu/web/s2-products#S2Products-NamingConventionS2-Products-Naming-Conventiontrue)\n",
227217
"* Landsat-8 Collection 2 jobs are submitted using [USGS scene IDs](https://www.usgs.gov/faqs/what-naming-convention-landsat-collection-2-level-1-and-level-2-scenes?qt-news_science_products=0#qt-news_science_products)"
228218
]
229219
},
@@ -397,7 +387,7 @@
397387
],
398388
"metadata": {
399389
"kernelspec": {
400-
"display_name": "Python 3",
390+
"display_name": "Python 3 (ipykernel)",
401391
"language": "python",
402392
"name": "python3"
403393
},
@@ -411,9 +401,9 @@
411401
"name": "python",
412402
"nbconvert_exporter": "python",
413403
"pygments_lexer": "ipython3",
414-
"version": "3.8.8"
404+
"version": "3.11.13"
415405
}
416406
},
417407
"nbformat": 4,
418-
"nbformat_minor": 1
408+
"nbformat_minor": 4
419409
}

docs/search_other_user_jobs.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"from hyp3_sdk import HyP3\n",
1515
"\n",
1616
"\n",
17-
"hyp3 = HyP3(prompt='token')\n",
17+
"hyp3 = HyP3(prompt='password')\n",
1818
"my_rtc_jobs = hyp3.find_jobs(name='rtc-example')"
1919
]
2020
},

0 commit comments

Comments
 (0)