pysll 0.2.3__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.
- pysll-0.2.3/LICENSE +28 -0
- pysll-0.2.3/PKG-INFO +12 -0
- pysll-0.2.3/README.md +187 -0
- pysll-0.2.3/pyproject.toml +9 -0
- pysll-0.2.3/pysll/__init__.py +3 -0
- pysll-0.2.3/pysll/constellation.py +927 -0
- pysll-0.2.3/pysll/decoders.py +149 -0
- pysll-0.2.3/pysll/exceptions.py +108 -0
- pysll-0.2.3/pysll/feature_flags.py +17 -0
- pysll-0.2.3/pysll/functions.py +5632 -0
- pysll-0.2.3/pysll/models.py +842 -0
- pysll-0.2.3/pysll/unit_operations.py +843 -0
- pysll-0.2.3/pysll/utils.py +182 -0
- pysll-0.2.3/pysll.egg-info/PKG-INFO +12 -0
- pysll-0.2.3/pysll.egg-info/SOURCES.txt +26 -0
- pysll-0.2.3/pysll.egg-info/dependency_links.txt +1 -0
- pysll-0.2.3/pysll.egg-info/not-zip-safe +1 -0
- pysll-0.2.3/pysll.egg-info/requires.txt +8 -0
- pysll-0.2.3/pysll.egg-info/top_level.txt +2 -0
- pysll-0.2.3/setup.cfg +30 -0
- pysll-0.2.3/setup.py +3 -0
- pysll-0.2.3/tests/__init__.py +0 -0
- pysll-0.2.3/tests/conftest.py +36 -0
- pysll-0.2.3/tests/test_api.py +405 -0
- pysll-0.2.3/tests/test_constellation.py +377 -0
- pysll-0.2.3/tests/test_decoders.py +81 -0
- pysll-0.2.3/tests/test_variable_unit.py +94 -0
pysll-0.2.3/LICENSE
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2023], [Emerald Cloud Lab]
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
pysll-0.2.3/PKG-INFO
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pysll
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Requires-Python: >=3.10
|
|
5
|
+
License-File: LICENSE
|
|
6
|
+
Requires-Dist: boto3>=1.26.62
|
|
7
|
+
Requires-Dist: backoff>=1.10.0
|
|
8
|
+
Requires-Dist: requests>=2.22.0
|
|
9
|
+
Requires-Dist: rollbar>=0.14.7
|
|
10
|
+
Requires-Dist: xmltodict>=0.13.0
|
|
11
|
+
Provides-Extra: numpy
|
|
12
|
+
Requires-Dist: numpy>=1.26.4; extra == "numpy"
|
pysll-0.2.3/README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# PySLL
|
|
2
|
+
SDKs and example code for accessing the Constellation APIs that power Emerald Cloud Lab.
|
|
3
|
+
|
|
4
|
+
## The constellation API
|
|
5
|
+
Detailed documentation about the Constellation API can be found at www.emeraldcloudlab.com/internal-developers-api.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
Install with pip:
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
pip install pysll
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
To use the SDK:
|
|
15
|
+
``` python
|
|
16
|
+
>>> from pysll import Constellation
|
|
17
|
+
>>> from pysll.models import Object
|
|
18
|
+
>>> client = Constellation()
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
To login:
|
|
22
|
+
``` python
|
|
23
|
+
>>> client.login("scientist@science.com", "myAwesomePassword")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
To get information about the current user once you are logged in:
|
|
27
|
+
``` python
|
|
28
|
+
>>> me = client.me()
|
|
29
|
+
>>> print(me)
|
|
30
|
+
{'Email': 'scientist@science.com', 'EmailAddress':'scientist@science.com', 'Id': 'id:abc123', 'Type': 'Object.User', 'Username': 'scientist'}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
To download information from an object:
|
|
34
|
+
``` python
|
|
35
|
+
>>> client.download(Object(me["Id"]), ["Name", "Email"])
|
|
36
|
+
["scientist", "scientist@science.com"]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
To search for objects of a specific type:
|
|
40
|
+
``` python
|
|
41
|
+
>>> client.search("Object.Data.Chromatography", "")
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Downloading data
|
|
45
|
+
|
|
46
|
+
You may perform a simple single field download like:
|
|
47
|
+
``` python
|
|
48
|
+
>>> client.download(Object("id:BYDOjvG4l3Ol"), "ColumnOrientation")
|
|
49
|
+
'Forward'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
You may download multiple fields in a single download like:
|
|
53
|
+
``` python
|
|
54
|
+
>>> client.download(Object("id:BYDOjvG4l3Ol"), ["SeparationMode", "ColumnOrientation"])
|
|
55
|
+
['ReversePhase', 'Forward']
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
You may download from multiple objects in a single download like:
|
|
59
|
+
``` python
|
|
60
|
+
>>> client.download([Object("id:o1k9jAkRM794"), Object("id:L8kPEjkw47jw")], "ColumnOrientation")
|
|
61
|
+
['Forward', 'Forward']
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
And finally, you may download multiple fields from multiple objects in a single download like:
|
|
65
|
+
``` python
|
|
66
|
+
>>> client.download([Object("id:o1k9jAkRM794"), Object("id:L8kPEjkw47jw")], ["SeparationMode", "ColumnOrientation"])
|
|
67
|
+
[['ReversePhase', 'Forward'], ['ReversePhase', 'Forward']]
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
You may also traverse links within downloads, like:
|
|
71
|
+
``` python
|
|
72
|
+
>>> client.download(Object("id:BYDOjvG4l3Ol"), "Instrument[Model[Name]]")
|
|
73
|
+
'Waters Acquity UPLC H-Class ELS with Pre-Column Heater'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
You can also download all of the fields on an object by not specifying a field. For example:
|
|
77
|
+
``` python
|
|
78
|
+
>>> client.download(Object("id:Z1lqpMzvkGMV"))
|
|
79
|
+
{'type': 'Object.User.Emerald.Developer', 'id': 'id:Z1lqpMzvkGMV'....}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Or via the "All" implicit field:
|
|
83
|
+
``` python
|
|
84
|
+
>>> client.download(Object("id:Z1lqpMzvkGMV"), "All")
|
|
85
|
+
{'type': 'Object.User.Emerald.Developer', 'id': 'id:Z1lqpMzvkGMV'....}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Note that in this case, the results will be a dictionary mapping field name to field value
|
|
89
|
+
|
|
90
|
+
## Dealing with types
|
|
91
|
+
|
|
92
|
+
There are a number of different ways to interpret field values based off the type of data stored in the object. String, integer, and real fields are mapped to their corresponding python types - for example:
|
|
93
|
+
``` python
|
|
94
|
+
>>> client.download(Object("id:BYDOjvG4l3Ol"), ["SeparationMode", "InjectionIndex"])
|
|
95
|
+
['ReversePhase', 28]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Link fields will return objects, which you can chain downloads off of (although note that traversals will be much faster):
|
|
99
|
+
``` python
|
|
100
|
+
>>> client.download(Object("id:BYDOjvG4l3Ol"), "Instrument")
|
|
101
|
+
Object[Instrument[HPLC, "id:wqW9BP4ARZVw"]
|
|
102
|
+
>>> client.download(client.download(Object("id:BYDOjvG4l3Ol"), "Instrument"), "Name")
|
|
103
|
+
'Galadriel'
|
|
104
|
+
>>> client.download(Object("id:BYDOjvG4l3Ol"), "Instrument[Name]")
|
|
105
|
+
'Galadriel'
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Date fields will be converted to native python datetime objects:
|
|
109
|
+
``` python
|
|
110
|
+
>>> client.download(Object("id:BYDOjvG4l3Ol"), "DateCreated")
|
|
111
|
+
datetime.datetime(2022, 1, 9, 23, 44, 31, 746154)
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Quantity arrays will be converted to python variable unit objects:
|
|
115
|
+
``` python
|
|
116
|
+
>>> client.download(Object("id:BYDOjvG4l3Ol"), "Scattering")
|
|
117
|
+
[[0.0 Minutes, -87.528984 IndependentUnit[Lsus]], [0.016667 Minutes, -96.701614 IndependentUnit[Lsus]], [0.033333 Minutes, -43.93272 IndependentUnit[Lsus]], [0.05 Minutes, -132.207855 IndependentUnit[Lsus]]...
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
which you may manipulate to get their values and units:
|
|
121
|
+
``` python
|
|
122
|
+
>>> scattering_info = client.download(Object("id:BYDOjvG4l3Ol"), "Scattering")
|
|
123
|
+
>>> len(scattering_info)
|
|
124
|
+
361
|
|
125
|
+
>>> scattering_info[0]
|
|
126
|
+
[0.0 Minutes, -87.528984 IndependentUnit[Lsus]]
|
|
127
|
+
>>> scattering_info[0][0]
|
|
128
|
+
0.0 Minutes
|
|
129
|
+
>>> scattering_info[0][0].value
|
|
130
|
+
0.0
|
|
131
|
+
>>> scattering_info[0][0].unit
|
|
132
|
+
'Minutes'
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Blob refs will be downloaded and automatically parsed in the same way:
|
|
136
|
+
```python
|
|
137
|
+
>>> client.download(Object("id:BYDOjvG4l3Ol"), "Absorbance")
|
|
138
|
+
[[0.0 'Minutes', 0.0 'Milli' 'AbsorbanceUnit'], [0.0008333333535119891 'Minutes', 0.0 'Milli' 'AbsorbanceUnit']...
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Additionally, you can download multiple fields that have different units the same as you would download other fields. For example:
|
|
142
|
+
```python
|
|
143
|
+
>>> client.download(Object("id:O81aEB16GlJ1"), "Composition")
|
|
144
|
+
[[4.977777777777776 Times[Power["Liters", -1], "Milligrams"], Object[Model[Molecule, "id:E8zoYvN6m61A"]], [75.11111111111111 IndependentUnit["VolumePercent"], Object[Model[Molecule, "id:vXl9j57PmP5D"]]]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Finally, you can download association fields and they will be automatically translated into python structures. For example:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
>>> client.download(Object("id:XnlV5jKZwmp3"), "ResolvedOptions")['Instrument']
|
|
151
|
+
Object[Instrument[HPLC, "id:wqW9BP4ARZVw"]
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Download Files
|
|
155
|
+
|
|
156
|
+
Files are controlled via the `auto_download_cloud_files` flag to the download function. By default, they will be returned as objects and not downloaded.
|
|
157
|
+
|
|
158
|
+
For example:
|
|
159
|
+
```python
|
|
160
|
+
>>> client.download(Object("id:BYDOjvG4l3Ol"), "DataFile")
|
|
161
|
+
Object[EmeraldCloudFile, "id:9RdZXv1jDAZ6"]
|
|
162
|
+
````
|
|
163
|
+
|
|
164
|
+
These may be manually downloaded via:
|
|
165
|
+
```python
|
|
166
|
+
>>> client.download_cloud_file(client.download(Object("id:BYDOjvG4l3Ol"), "DataFile"))
|
|
167
|
+
'/var/folders/j_/ftdn14ms37s40j2z0h1wzxbw0000gn/T/tmp6krhb8lp/Absorbance Raw File.bin_absorbancefile'
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
or, it is possible to automatically download them by using the `auto_download_cloud_files` flag of download:
|
|
171
|
+
```python
|
|
172
|
+
>>> data_file = client.download(Object("id:BYDOjvG4l3Ol"), "DataFile", auto_download_cloud_files=True)
|
|
173
|
+
>>> data_file.local_path
|
|
174
|
+
'/var/folders/j_/ftdn14ms37s40j2z0h1wzxbw0000gn/T/tmp6krhb8lp/Absorbance Raw File_1.bin_absorbancefile'
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The format of these files can often change, but the sdk is pretty smart about interpreting them. Once you have downloaded
|
|
178
|
+
the file, you can have the sdk attempt to parse it into python structs via the following:
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
>>> data_file = client.download(Object("id:BYDOjvG4l3Ol"), "DataFile", auto_download_cloud_files=True)
|
|
182
|
+
>>> from constellation_field_parser import ConstellationFieldParser
|
|
183
|
+
>>> ConstellationFieldParser().parse_local_file(data_file.local_path)
|
|
184
|
+
[[0.0 'Minutes', 273.0 'Nanometers', 0.0 'Milli' 'AbsorbanceUnit'], [0.0008333333535119891 'Minutes', 273.0 'Nanometers', 0.0 'Milli' 'AbsorbanceUnit']...
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
If the field parser is unable to parse the file, it will return `None`.
|