ee-client 1.2.1__tar.gz → 1.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ee_client-1.2.1 → ee_client-1.2.2}/PKG-INFO +1 -1
- {ee_client-1.2.1 → ee_client-1.2.2}/ee_client.egg-info/PKG-INFO +1 -1
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/__init__.py +1 -1
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/client.py +13 -4
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/data.py +1 -1
- {ee_client-1.2.1 → ee_client-1.2.2}/pyproject.toml +2 -2
- {ee_client-1.2.1 → ee_client-1.2.2}/tests/test_data.py +1 -1
- {ee_client-1.2.1 → ee_client-1.2.2}/tests/test_models.py +1 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/LICENSE +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/README.rst +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/ee_client.egg-info/SOURCES.txt +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/ee_client.egg-info/dependency_links.txt +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/ee_client.egg-info/requires.txt +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/ee_client.egg-info/top_level.txt +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/exceptions.py +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/export/image.py +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/export/table.py +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/helpers.py +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/logger.py +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/oauth_app.py +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/tasks.py +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/eeclient/typing.py +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/setup.cfg +0 -0
- {ee_client-1.2.1 → ee_client-1.2.2}/tests/test_client.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ee-client
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: extends the capabilities of the earthengine-api by providing custom session management and client interactions
|
|
5
5
|
Author-email: Daniel Guerrero <dfgm2006@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/dfguerrerom/ee-client
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: ee-client
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: extends the capabilities of the earthengine-api by providing custom session management and client interactions
|
|
5
5
|
Author-email: Daniel Guerrero <dfgm2006@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/dfguerrerom/ee-client
|
|
@@ -65,11 +65,16 @@ class EESession:
|
|
|
65
65
|
"""Initialize credentials from the initial Google tokens"""
|
|
66
66
|
_google_tokens = self.sepal_user_data.google_tokens
|
|
67
67
|
|
|
68
|
+
if not _google_tokens:
|
|
69
|
+
raise EEClientError("No google tokens found in the user data.")
|
|
70
|
+
|
|
68
71
|
self.expiry_date = _google_tokens.access_token_expiry_date
|
|
69
72
|
self.project_id = _google_tokens.project_id
|
|
70
73
|
self._credentials = _google_tokens
|
|
71
74
|
|
|
72
|
-
def get_assets_folder(self) -> str:
|
|
75
|
+
async def get_assets_folder(self) -> str:
|
|
76
|
+
if self.is_expired():
|
|
77
|
+
await self.set_credentials()
|
|
73
78
|
return f"projects/{self.project_id}/assets/"
|
|
74
79
|
|
|
75
80
|
def is_expired(self) -> bool:
|
|
@@ -81,6 +86,8 @@ class EESession:
|
|
|
81
86
|
if not self._credentials:
|
|
82
87
|
raise EEClientError("No credentials available")
|
|
83
88
|
|
|
89
|
+
logger.debug(f"Getting headers with project id: {self.project_id}")
|
|
90
|
+
|
|
84
91
|
data = {
|
|
85
92
|
"x-goog-user-project": self.project_id,
|
|
86
93
|
"Authorization": f"Bearer {self._credentials.access_token}",
|
|
@@ -143,11 +150,11 @@ class EESession:
|
|
|
143
150
|
self.expiry_date = self._credentials.access_token_expiry_date
|
|
144
151
|
self.project_id = (
|
|
145
152
|
self._credentials.project_id
|
|
146
|
-
if
|
|
153
|
+
if self.enforce_project_id
|
|
147
154
|
else self.project_id
|
|
148
155
|
)
|
|
149
156
|
logger.debug(
|
|
150
|
-
f"Successfully refreshed credentials !{self._credentials}."
|
|
157
|
+
f"Successfully refreshed credentials !{self._credentials}==================. {self.project_id}"
|
|
151
158
|
)
|
|
152
159
|
return
|
|
153
160
|
else:
|
|
@@ -180,7 +187,9 @@ class EESession:
|
|
|
180
187
|
try:
|
|
181
188
|
async with self.get_client() as client:
|
|
182
189
|
url_with_project = self.set_url_project(url)
|
|
183
|
-
logger.debug(
|
|
190
|
+
logger.debug(
|
|
191
|
+
f"Making async {method} request to {url_with_project} with data: {data}"
|
|
192
|
+
)
|
|
184
193
|
response = await client.request(
|
|
185
194
|
method, url_with_project, json=data, params=params
|
|
186
195
|
)
|
|
@@ -211,7 +211,7 @@ async def create_folder(client: "EESession", folder: Union[Path, str]) -> str:
|
|
|
211
211
|
if not folder or not folder.strip("/"):
|
|
212
212
|
raise ValueError("Folder path cannot be empty")
|
|
213
213
|
|
|
214
|
-
full_path = str(client.get_assets_folder() / Path(folder))
|
|
214
|
+
full_path = str(await client.get_assets_folder() / Path(folder))
|
|
215
215
|
|
|
216
216
|
if asset := await get_asset(client, full_path):
|
|
217
217
|
logger.debug(f"Folder already exists: {full_path}")
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "ee-client"
|
|
7
|
-
version = "1.2.
|
|
7
|
+
version = "1.2.2"
|
|
8
8
|
description = "extends the capabilities of the earthengine-api by providing custom session management and client interactions"
|
|
9
9
|
readme = { file = "README.rst", content-type = "text/x-rst" }
|
|
10
10
|
authors = [
|
|
@@ -66,7 +66,7 @@ branch = true
|
|
|
66
66
|
[tool.commitizen]
|
|
67
67
|
tag_format = "v$major.$minor.$patch$prerelease"
|
|
68
68
|
update_changelog_on_bump = false
|
|
69
|
-
version = "1.2.
|
|
69
|
+
version = "1.2.2"
|
|
70
70
|
version_files = [
|
|
71
71
|
"pyproject.toml:version",
|
|
72
72
|
"eeclient/__init__.py:__version__",
|
|
@@ -56,7 +56,7 @@ async def test_delete_asset(sepal_headers):
|
|
|
56
56
|
sepal_session = EESession(sepal_headers=sepal_headers)
|
|
57
57
|
await create_folder(sepal_session, folder="1/2/3/4/5/65/")
|
|
58
58
|
|
|
59
|
-
folder_to_delete = str(Path(sepal_session.get_assets_folder()) / "1/")
|
|
59
|
+
folder_to_delete = str(Path(await sepal_session.get_assets_folder()) / "1/")
|
|
60
60
|
|
|
61
61
|
with pytest.raises(EERestException) as excinfo:
|
|
62
62
|
await delete_asset(sepal_session, asset_id=folder_to_delete)
|
|
@@ -15,6 +15,7 @@ def test_headers(dummy_headers):
|
|
|
15
15
|
assert sepal_headers.cookies == {"SEPAL-SESSIONID": "s:random"}
|
|
16
16
|
assert sepal_headers.sepal_user.id == 10001
|
|
17
17
|
assert sepal_headers.sepal_user.username == "admin"
|
|
18
|
+
assert sepal_headers.sepal_user.google_tokens
|
|
18
19
|
assert sepal_headers.sepal_user.google_tokens.access_token
|
|
19
20
|
assert sepal_headers.sepal_user.google_tokens.refresh_token
|
|
20
21
|
assert sepal_headers.sepal_user.google_tokens.project_id == "ee-project"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|