commonlib-reader 1.1.3__tar.gz → 1.2.1__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.
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/PKG-INFO +2 -4
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/pyproject.toml +3 -5
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/src/commonlib_reader/connector.py +1 -1
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/src/commonlib_reader/facility.py +9 -1
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/src/commonlib_reader/ims.py +11 -9
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/src/commonlib_reader/utils.py +1 -1
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/README.md +0 -0
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/src/commonlib_reader/__init__.py +0 -0
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/src/commonlib_reader/discipline.py +0 -0
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/src/commonlib_reader/tag.py +0 -0
- {commonlib_reader-1.1.3 → commonlib_reader-1.2.1}/src/commonlib_reader/unit.py +0 -0
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: commonlib-reader
|
|
3
|
-
Version: 1.1
|
|
3
|
+
Version: 1.2.1
|
|
4
4
|
Summary: Reader for Equinor commonlib api.
|
|
5
5
|
Author: Åsmund Våge Fannemel
|
|
6
6
|
Author-email: Åsmund Våge Fannemel <asmf@equinor.com>
|
|
7
7
|
License: MIT
|
|
8
8
|
Requires-Dist: pandas>=2.1.4
|
|
9
|
-
Requires-Dist:
|
|
10
|
-
Requires-Dist: urllib3>=2.5.0
|
|
11
|
-
Requires-Dist: eq-api-connector>=1.0.0,<2.0.0
|
|
9
|
+
Requires-Dist: eq-api-connector>=1.1.0,<2.0.0
|
|
12
10
|
Requires-Python: >=3.10, <4.0.0
|
|
13
11
|
Project-URL: Repository, https://github.com/equinor/commonlib-reader.git
|
|
14
12
|
Description-Content-Type: text/markdown
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "commonlib-reader"
|
|
3
|
-
version = "1.1
|
|
3
|
+
version = "1.2.1"
|
|
4
4
|
description = "Reader for Equinor commonlib api."
|
|
5
5
|
authors = [
|
|
6
6
|
{ name = "Åsmund Våge Fannemel", email = "asmf@equinor.com" }
|
|
@@ -11,14 +11,12 @@ urls = {"Repository" = "https://github.com/equinor/commonlib-reader.git"}
|
|
|
11
11
|
requires-python = ">=3.10,<4.0.0"
|
|
12
12
|
dependencies = [
|
|
13
13
|
"pandas>=2.1.4",
|
|
14
|
-
"
|
|
15
|
-
"urllib3>=2.5.0", # Pinned to avoid security issues in some older versions
|
|
16
|
-
"eq-api-connector (>=1.0.0,<2.0.0)"
|
|
14
|
+
"eq-api-connector (>=1.1.0,<2.0.0)"
|
|
17
15
|
]
|
|
18
16
|
|
|
19
17
|
[dependency-groups]
|
|
20
18
|
dev = [
|
|
21
|
-
"pytest>=7.4.4,<
|
|
19
|
+
"pytest>=7.4.4,<10.0.0",
|
|
22
20
|
"pytest-cov>=7.0.0,<8.0.0",
|
|
23
21
|
"black>=24.1.1,<27.0.0"
|
|
24
22
|
]
|
|
@@ -14,7 +14,7 @@ def get_connector() -> APIConnector:
|
|
|
14
14
|
clientID = "728cfddd-b8e9-4ed7-b9a3-8f2fd5b8e79a"
|
|
15
15
|
scopes = ["37d598fc-da0f-46bd-949f-7107918d47a5/user_impersonation"]
|
|
16
16
|
connector = APIConnector(client_id=clientID, scope=scopes)
|
|
17
|
-
connector.
|
|
17
|
+
connector.url_prod = "https://commonlibapi.equinor.com/"
|
|
18
18
|
_connector = connector
|
|
19
19
|
|
|
20
20
|
return _connector
|
|
@@ -46,6 +46,14 @@ class Facility:
|
|
|
46
46
|
except (TypeError, ValueError):
|
|
47
47
|
pass
|
|
48
48
|
|
|
49
|
+
def __eq__(self, other):
|
|
50
|
+
if isinstance(other, Facility):
|
|
51
|
+
return self.identity == other.identity and self._data == other._data
|
|
52
|
+
return False
|
|
53
|
+
|
|
54
|
+
def __str__(self):
|
|
55
|
+
return f"Facility(identity={self.identity}, name={self.description})"
|
|
56
|
+
|
|
49
57
|
@property
|
|
50
58
|
def identity(self) -> str:
|
|
51
59
|
return self._data.get("identity", "")
|
|
@@ -226,7 +234,7 @@ class Facility:
|
|
|
226
234
|
@classmethod
|
|
227
235
|
def get_sap_facilities(cls) -> List["Facility"]:
|
|
228
236
|
fac = cls.get_all_facilities()
|
|
229
|
-
return [f for f in fac if len(f.sap) > 0]
|
|
237
|
+
return [f for f in fac if len(f.sap) > 0 and f.sap.isdigit()]
|
|
230
238
|
|
|
231
239
|
@classmethod
|
|
232
240
|
def get_ioc_facilities(cls) -> List["Facility"]:
|
|
@@ -60,9 +60,10 @@ class IMS:
|
|
|
60
60
|
@staticmethod
|
|
61
61
|
def from_facility(facility: Union[Facility, str, int]) -> "IMS":
|
|
62
62
|
"""Get IMS instance from STID code.
|
|
63
|
+
If no IMS instance is found for the input facility, will try to find IMS instance for parent facility recursively.
|
|
63
64
|
|
|
64
65
|
Args:
|
|
65
|
-
facility (str): Facility inst code (STID) or SAP code.
|
|
66
|
+
facility (Facility, str, int): Facility object, inst code (STID) or SAP code.
|
|
66
67
|
|
|
67
68
|
Raises:
|
|
68
69
|
ValueError: Not able to instantiate IMS object from input facility code.
|
|
@@ -70,18 +71,15 @@ class IMS:
|
|
|
70
71
|
Returns:
|
|
71
72
|
IMS: IMS instance
|
|
72
73
|
"""
|
|
73
|
-
if isinstance(facility,
|
|
74
|
+
if not isinstance(facility, Facility):
|
|
74
75
|
facility = Facility(facility)
|
|
75
76
|
|
|
76
|
-
if isinstance(facility, Facility):
|
|
77
|
-
facility = facility.identity
|
|
78
|
-
|
|
79
|
-
if not isinstance(facility, str) or len(facility) == 0:
|
|
80
|
-
raise ValueError("Not able to detect facility from input {facility}.")
|
|
81
|
-
|
|
82
77
|
ims = IMS.get_ims_list(facility=facility)
|
|
83
78
|
if len(ims) == 1:
|
|
84
79
|
return ims[0]
|
|
80
|
+
if len(ims) == 0:
|
|
81
|
+
if facility.parent_facility:
|
|
82
|
+
return IMS.from_facility(facility.parent_facility)
|
|
85
83
|
|
|
86
84
|
raise ValueError(f"Not able to get IMS object for facility {facility}")
|
|
87
85
|
|
|
@@ -98,7 +96,7 @@ class IMS:
|
|
|
98
96
|
return [IMS(x) for x in cls._ims_codes]
|
|
99
97
|
|
|
100
98
|
@staticmethod
|
|
101
|
-
def get_ims_list(facility: str = "") -> List["IMS"]:
|
|
99
|
+
def get_ims_list(facility: Union[str, Facility] = "") -> List["IMS"]:
|
|
102
100
|
"""Get list of IMS objects.
|
|
103
101
|
|
|
104
102
|
Args:
|
|
@@ -107,6 +105,10 @@ class IMS:
|
|
|
107
105
|
Returns:
|
|
108
106
|
List[IMS]: list of IMS objects
|
|
109
107
|
"""
|
|
108
|
+
|
|
109
|
+
if isinstance(facility, Facility):
|
|
110
|
+
facility = facility.identity
|
|
111
|
+
|
|
110
112
|
i = IMS._get_ims_codes()
|
|
111
113
|
if len(facility) > 0:
|
|
112
114
|
return [x for x in i if x.facility == facility]
|
|
@@ -60,7 +60,7 @@ def post_sql(sql: str, take: int = 100, skip: int = 0) -> list:
|
|
|
60
60
|
list: List of response from api
|
|
61
61
|
"""
|
|
62
62
|
|
|
63
|
-
url = urljoin(get_connector().
|
|
63
|
+
url = urljoin(get_connector().url, "api/sql")
|
|
64
64
|
response = requests.post(
|
|
65
65
|
url=url,
|
|
66
66
|
json={"query": sql, "take": take, "skip": skip},
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|