ellipsis 3.1.6__py3-none-any.whl → 3.1.8__py3-none-any.whl

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.

Potentially problematic release.


This version of ellipsis might be problematic. Click here for more details.

ellipsis/__init__.py CHANGED
@@ -7,4 +7,4 @@ from ellipsis import path
7
7
  from ellipsis import view
8
8
  from ellipsis import util
9
9
 
10
- __version__ = '3.1.6'
10
+ __version__ = '3.1.8'
ellipsis/apiManager.py CHANGED
@@ -89,39 +89,52 @@ def call(method, url, body = None, token = None, crash = True):
89
89
  return r
90
90
 
91
91
 
92
- def upload(url, filePath, body, token, key = 'data'):
92
+ def upload(url, filePath, body, token, key = 'data', memfile= None):
93
93
  body = filterNone(body)
94
-
95
94
  seperator = os.path.sep
96
95
  fileName = filePath.split(seperator)[len(filePath.split(seperator))-1 ]
96
+
97
+ if str(type(memfile)) == str(type(None)):
98
+ conn_file = open(filePath, 'rb')
99
+ else:
100
+ conn_file = memfile
101
+
102
+ payload = MultipartEncoder(fields = {**body, key: (fileName, conn_file, 'application/octet-stream')})
103
+
97
104
 
98
105
  for k in body.keys():
99
106
  body[k] = str(body[k])
100
107
 
101
- conn_file = open(filePath, 'rb')
102
-
103
- payload = MultipartEncoder(fields = {**body, key: (fileName, conn_file, 'application/octet-stream')})
104
108
 
105
109
  token = 'Bearer ' + token
106
110
 
107
111
  r = requests.post(baseUrl + url, headers = {"Authorization":token, "Content-Type": payload.content_type}, data=payload)
108
- conn_file.close()
112
+
113
+ if str(type(memfile)) == str(type(None)):
114
+ conn_file.close()
109
115
 
110
116
  if r.status_code != 200:
111
117
  raise ValueError(r.text)
112
118
  return r.json()
113
119
 
114
- def download(url, filePath, token):
120
+ def download(url, filePath, token, memfile = None):
115
121
 
116
122
  token = 'Bearer ' + token
117
123
  with requests.get(baseUrl + url, stream=True, headers={"Authorization": token}) as r:
118
124
  r.raise_for_status()
119
- with open(filePath, 'wb') as f:
125
+ if str(type(memfile)) == str(type(None)):
126
+ with open(filePath, 'wb') as f:
127
+ for chunk in r.iter_content(chunk_size=8192):
128
+ # If you have chunk encoded response uncomment if
129
+ # and set chunk_size parameter to None.
130
+ #if chunk:
131
+ f.write(chunk)
132
+ else:
120
133
  for chunk in r.iter_content(chunk_size=8192):
121
134
  # If you have chunk encoded response uncomment if
122
135
  # and set chunk_size parameter to None.
123
136
  #if chunk:
124
- f.write(chunk)
137
+ memfile.write(chunk)
125
138
 
126
139
 
127
140
 
@@ -1,2 +1,2 @@
1
- from ellipsis.path.file.root import download
2
- from ellipsis.path.file.root import add
1
+ from ellipsis.path.file.root import download, add, addPickle, getPickle, addCsv, getCsv, addJson, getJson
2
+
@@ -2,6 +2,26 @@ from ellipsis import apiManager
2
2
  from ellipsis import sanitize
3
3
 
4
4
  import os
5
+ import pickle
6
+ from io import BytesIO
7
+ import json
8
+ import pandas as pd
9
+
10
+
11
+ def add( filePath, token, parentId = None, publicAccess =None, metadata=None):
12
+ token = sanitize.validString('token', token, True)
13
+ parentId = sanitize.validUuid('parentId', parentId, False)
14
+ publicAccess = sanitize.validObject('publicAccess', publicAccess, False)
15
+ metadata = sanitize.validObject('metadata', metadata, False)
16
+
17
+
18
+
19
+ seperator = os.path.sep
20
+ fileName = filePath.split(seperator)[len(filePath.split(seperator))-1 ]
21
+
22
+ body = {'name':fileName, 'publicAccess':publicAccess, 'metadata':metadata, 'parentId':parentId}
23
+ r = apiManager.upload('/path/file' , filePath, body, token, key = 'data')
24
+ return r
5
25
 
6
26
 
7
27
  def download(pathId, filePath, token=None):
@@ -14,12 +34,113 @@ def download(pathId, filePath, token=None):
14
34
 
15
35
 
16
36
 
17
- def add( filePath, token, parentId = None, publicAccess =None, metadata=None):
37
+ def addCsv(df, name, token, parentId = None, publicAccess =None, metadata=None):
18
38
  token = sanitize.validString('token', token, True)
19
-
20
- seperator = os.path.sep
21
- fileName = filePath.split(seperator)[len(filePath.split(seperator))-1 ]
22
-
23
- body = {'name':fileName, 'publicAccess':publicAccess, 'metadata':metadata, 'parentId':parentId}
24
- r = apiManager.upload('/path/file' , filePath, body, token, key = 'data')
25
- return r
39
+ name = sanitize.validString('name', name, True)
40
+ df = sanitize.validPandas('df', df, True)
41
+
42
+ parentId = sanitize.validUuid('parentId', parentId, False)
43
+ publicAccess = sanitize.validObject('publicAccess', publicAccess, False)
44
+ metadata = sanitize.validObject('metadata', metadata, False)
45
+
46
+ memfile = BytesIO()
47
+ df.to_csv(memfile)
48
+
49
+
50
+ body = {'name':name, 'publicAccess':publicAccess, 'metadata':metadata, 'parentId':parentId}
51
+ r = apiManager.upload('/path/file' , name, body, token, key='data', memfile = memfile)
52
+
53
+
54
+ return r
55
+
56
+ def getCsv(pathId, token=None):
57
+ pathId = sanitize.validUuid('pathId', pathId, True)
58
+ token = sanitize.validString('token', token, False)
59
+
60
+
61
+ r = apiManager.get('/path/' + pathId + '/file/data', {}, token)
62
+
63
+
64
+ memfile = BytesIO(bytes(r, 'utf-8'))
65
+ try:
66
+ df = pd.read_csv(memfile)
67
+ except:
68
+ raise ValueError('Read file is not a valid CSV')
69
+ return df
70
+
71
+
72
+
73
+ def addJson(d, name, token, parentId = None, publicAccess =None, metadata=None):
74
+ token = sanitize.validString('token', token, True)
75
+ name = sanitize.validString('name', name, True)
76
+ d = sanitize.validObject('d', d, True)
77
+
78
+ parentId = sanitize.validUuid('parentId', parentId, False)
79
+ publicAccess = sanitize.validObject('publicAccess', publicAccess, False)
80
+ metadata = sanitize.validObject('metadata', metadata, False)
81
+
82
+ memfile = BytesIO()
83
+ d = json.dumps(d)
84
+ memfile.write(bytes(d, 'utf-8'))
85
+
86
+
87
+ body = {'name':name, 'publicAccess':publicAccess, 'metadata':metadata, 'parentId':parentId}
88
+ r = apiManager.upload('/path/file' , name, body, token, key='data', memfile = memfile)
89
+
90
+
91
+ return r
92
+
93
+
94
+ def getJson(pathId, token=None):
95
+ pathId = sanitize.validUuid('pathId', pathId, True)
96
+ token = sanitize.validString('token', token, False)
97
+
98
+ memfile = BytesIO()
99
+ apiManager.download('/path/' + pathId + '/file/data', '', token, memfile)
100
+ memfile.seek(0)
101
+ try:
102
+ x = json.load(memfile)
103
+ except:
104
+ raise ValueError('Read file not a valid pickle file')
105
+
106
+
107
+ return x
108
+
109
+
110
+
111
+ def addPickle(x, name, token, parentId = None, publicAccess =None, metadata=None):
112
+ token = sanitize.validString('token', token, True)
113
+ name = sanitize.validString('name', name, True)
114
+ parentId = sanitize.validUuid('parentId', parentId, False)
115
+ publicAccess = sanitize.validObject('publicAccess', publicAccess, False)
116
+ metadata = sanitize.validObject('metadata', metadata, False)
117
+
118
+ memfile = BytesIO()
119
+ pickle.dump(x, memfile)
120
+
121
+ body = {'name':name, 'publicAccess':publicAccess, 'metadata':metadata, 'parentId':parentId}
122
+ r = apiManager.upload('/path/file' , name, body, token, key='data', memfile = memfile)
123
+
124
+ return r
125
+
126
+
127
+ def getPickle(pathId, token=None):
128
+ pathId = sanitize.validUuid('pathId', pathId, True)
129
+ token = sanitize.validString('token', token, False)
130
+
131
+ memfile = BytesIO()
132
+ apiManager.download('/path/' + pathId + '/file/data', '', token, memfile)
133
+ memfile.seek(0)
134
+ try:
135
+ x = pickle.load(memfile)
136
+ except:
137
+ raise ValueError('Read file not a valid pickle file')
138
+
139
+
140
+ return x
141
+
142
+
143
+
144
+
145
+
146
+
ellipsis/sanitize.py CHANGED
@@ -68,7 +68,13 @@ def validUuidArray(name, value, required):
68
68
  raise ValueError(name + ' must be a list of uuids')
69
69
  return(value)
70
70
 
71
+ def validPandas(name, value, required):
72
+ if not required and type(value) == type(None):
73
+ return
71
74
 
75
+ if type(value) != type(pd.DataFrame()):
76
+ raise ValueError(name + 'must be of type pandas data frame')
77
+ return(value)
72
78
 
73
79
  def validString(name, value, required):
74
80
  if not required and type(value) == type(None):
@@ -1,31 +1,29 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ellipsis
3
- Version: 3.1.6
3
+ Version: 3.1.8
4
4
  Summary: Package to interact with the Ellipsis API
5
5
  Home-page: https://github.com/ellipsis-drive-internal/python-package
6
6
  Author: Daniel van der Maas
7
7
  Author-email: daniel@ellipsis-drive.com
8
- License: UNKNOWN
9
- Platform: UNKNOWN
10
8
  Classifier: Programming Language :: Python :: 3
11
9
  Classifier: License :: OSI Approved :: MIT License
12
10
  Classifier: Operating System :: OS Independent
13
11
  Requires-Python: >=3.6
14
12
  Description-Content-Type: text/markdown
15
13
  License-File: LICENSE
16
- Requires-Dist: Fiona
14
+ Requires-Dist: pandas
17
15
  Requires-Dist: Pillow
18
- Requires-Dist: Shapely
19
- Requires-Dist: geopandas (==0.9.0)
20
- Requires-Dist: geopy
21
- Requires-Dist: imagecodecs
16
+ Requires-Dist: geopandas
17
+ Requires-Dist: pyproj
22
18
  Requires-Dist: numpy
23
- Requires-Dist: pandas
24
- Requires-Dist: pyproj (==3.0.1)
25
- Requires-Dist: rasterio
19
+ Requires-Dist: imagecodecs
26
20
  Requires-Dist: requests
27
21
  Requires-Dist: requests-toolbelt
22
+ Requires-Dist: rasterio
23
+ Requires-Dist: Shapely
24
+ Requires-Dist: geopy
28
25
  Requires-Dist: scikit-image
26
+ Requires-Dist: Fiona
29
27
  Requires-Dist: tifffile
30
28
 
31
29
  # Ellipsis Drive Python Package
@@ -64,5 +62,3 @@ Another example
64
62
  info = el.path.get(folderId, token)
65
63
  layers = el.path.listPath(folderId, pathType='layer', token = token, listAll = True)
66
64
  folders = el.path.listPath(folderId, pathType='folder', token = token, listAll = True)
67
-
68
-
@@ -1,14 +1,14 @@
1
- ellipsis/__init__.py,sha256=93GninuGlrB3AOG4w3NKKwibcLa_Tbx-8psQkH0QGGY,232
2
- ellipsis/apiManager.py,sha256=QU0LzYMivctlzUN9yLOTIF1ypAwvI9xsD9Nw_kJT1Yk,3302
3
- ellipsis/sanitize.py,sha256=YCxtl9DFA7oipf_oiAkGUrbvB3J3ZWUFNuk06s8Byq4,9745
1
+ ellipsis/__init__.py,sha256=H82wS2677cybsKg_xJMS528vNSog3hTt_KQnsCbfXdk,232
2
+ ellipsis/apiManager.py,sha256=aT-fRTngM_dV2KS7xEnR_E6OlFDGA1KPUFCHV_jeO7w,3819
3
+ ellipsis/sanitize.py,sha256=jltJfCkgyNYxsAmYCAFFIEMKnGK4edcMpnZqjbSxtp0,9982
4
4
  ellipsis/account/__init__.py,sha256=K40DMBaUDSxt3rO2WZv63Wmpfy49ocqBxvWqyIYHR24,92
5
5
  ellipsis/account/root.py,sha256=29IGUJavfXC9wLC_Fxzy1cdCbnP4QPmbYlE-H6VP088,1285
6
6
  ellipsis/account/accessToken/__init__.py,sha256=ivwhK1eC4g74PAKaeTReb1QhIpKXyvmfdqZV6wDY-EY,66
7
7
  ellipsis/account/accessToken/root.py,sha256=TYo8wTyWyzytaqOTsuQC-Vn3y7BhYMC88EItZafpISA,1281
8
8
  ellipsis/path/__init__.py,sha256=2AL0qA5fzPYtizw-baHA8l5J4MTG55giSdxJ3HrHzl8,398
9
9
  ellipsis/path/root.py,sha256=vw8p36-_rLAHuy7WUv793HRftxa3VIPmpmWtSdJiXOE,7609
10
- ellipsis/path/file/__init__.py,sha256=jpXoU1agFnEH1XzLSigJ8uNRC-5534I4kskuNpt-6us,85
11
- ellipsis/path/file/root.py,sha256=kXUfHXd_OmhjuCdDPS5vpCBoqlFPSfkAOAKex_1e6M8,829
10
+ ellipsis/path/file/__init__.py,sha256=i_KB1S1J9pZjcPTKdyGMnjJf2tCoHFzptLGaxmTi55A,107
11
+ ellipsis/path/file/root.py,sha256=zP4DF2dXswKnqHM7wsCN25SvjMdFll2AjHILJ41ihfQ,4417
12
12
  ellipsis/path/folder/__init__.py,sha256=HCeAZAWZSqUnWiSQYJjsVFe6AI9uKSS8tb5uTkSeAtI,91
13
13
  ellipsis/path/folder/root.py,sha256=Afof2u8LAutFL4XeHVtYZDJMCpRWfLuXEOXnBL4ETi4,1481
14
14
  ellipsis/path/hashtag/__init__.py,sha256=4u8VC7xOFJjuZ9K08yh6GsPn8YkYZ_24o_7viScUQlg,59
@@ -53,8 +53,8 @@ ellipsis/util/__init__.py,sha256=A3BEF6O5qTRU90yoaZDI-xF8R1WAFuh1fdxwWKd1Uvw,628
53
53
  ellipsis/util/root.py,sha256=d7CYEhiGb6RY5Ep7lDmIderiRfXnnPtW8f9ZJu0VTgg,19434
54
54
  ellipsis/view/__init__.py,sha256=91KyJzbSvwSP9hvJQyo1LLM48b5NixLz6G40I9h6sdY,67
55
55
  ellipsis/view/root.py,sha256=6actiBwIsM0f7sJhQl_U4j-C6Dhe0z5XGGtxIOIKdY8,1726
56
- ellipsis-3.1.6.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
57
- ellipsis-3.1.6.dist-info/METADATA,sha256=P5wVbXyxs2EB-Zu38neKQcTtkJGuko0-e6Et4oc4wDY,1805
58
- ellipsis-3.1.6.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
59
- ellipsis-3.1.6.dist-info/top_level.txt,sha256=eG8gfaVDyprKdb-dsGSh_lFMSa3DiZCsJFqze239RjA,9
60
- ellipsis-3.1.6.dist-info/RECORD,,
56
+ ellipsis-3.1.8.dist-info/LICENSE,sha256=7EI8xVBu6h_7_JlVw-yPhhOZlpY9hP8wal7kHtqKT_E,1074
57
+ ellipsis-3.1.8.dist-info/METADATA,sha256=0K6dLQuzzbYmcVfZ98TViYUBSaExqVc3Vhh__q7dUVY,1748
58
+ ellipsis-3.1.8.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
59
+ ellipsis-3.1.8.dist-info/top_level.txt,sha256=eG8gfaVDyprKdb-dsGSh_lFMSa3DiZCsJFqze239RjA,9
60
+ ellipsis-3.1.8.dist-info/RECORD,,