clarify-assets
Populate Clarify metadata through asset models.
Flow example
from clarify_assets import Asset, Attribute, AssetBroker
from pyclarify import Item
enterprise = Asset(
labels = [{"enterprise": "OG Inc"}]
)
station = Asset(
labels = [{"station": "work"}]
)
temperature = Attribute(
meta=Item(
name="Temperature",
labels={
"medium": ["Air"]
}
),
filter = {"name": "Temperature"}
)
climate = Asset(
labels=[{"cell": "climate"}],
attributes=[temperature]
)
station.append(climate)
enterprise.append(station)
enterprise.pretty_print(debug=True)
AB = AssetBroker(
credentials="credentials.json",
integrations=["integration1"]
)
AB.flush_and_build_db()
AB.assign_signals(enterprise)
enterprise.pretty_print(minimal=True)
AB.publish_asset(enterprise)
Custom attribute example
from clarify_assets import Attribute
from dataclasses import dataclass
def get_value_or_none(key, asset):
return list(filter(lambda x: x,
list(map(lambda x: x[key] if key in x.keys() else None,
asset.labels)
)
))
def get_line_number(string):
return string.lower().replace(" ", "").split("line")[-1]
@dataclass
class FishtalkAttribute(Attribute):
def __post_init__(self):
super().__post_init__()
self.independent = True
if self.meta:
i = self.meta.dict()
i["labels"]["data-source"] = ["Fishtalk"]
self.meta = Item(**i)
if self.labels:
area_label = get_value_or_none("area", self)
line_label = get_value_or_none("line", self)
if area_label and line_label:
line_no = get_line_number(line_label)
if len(line_no) == 1:
line_no = "0" + line_no
unit_label = area_label + "-" + line_no
self.filter = merge_filters(self.filter, {"labels.unit": [unit_label]})
@dataclass
class FishtalkBiomassCount(FishtalkAttribute):
meta: Item = Item(
name = "Biomasse antall",
engUnit = "stk",
visible = True,
)
def __post_init__(self):
self.filter = merge_filters(self.filter, {"name": "fishtalkparser.Closing Count"})
super().__post_init__()
Reusable attributes example
@dataclass
class ValveAeration(ScadaAttribute):
meta: Item = Item(
name = "Valve X",
engUnit = "",
valueType="enum",
enumValues={
"0": "Closed",
"1": "Open"
},
visible = True,
)
def __post_init__(self):
self.filter = merge_filters(self.filter, {"name": "Value"})
super().__post_init__()
valve_aeration_list = [
ValveAeration(name = f"Valve {i}", filter = {"labels.folder-3": [f"Valve_Aeriation_{i}"]})
for i in range(1,9)
]
Reusable attributes with different filters
va = ValveAeration()
house = Asset(
labels=[{"site":"home"}],
attributes=[
va.copy(
name="Aeration Kitchen",
add_filter={
"labels.room": "Kitchen"
}
),
va.copy(
name="Aeration Living room",
add_filter={
"labels.room": "Living room"
}
)
]
)
Metadata
Release files for clarify-assets 0.0.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| clarify_assets-0.0.10.tar.gz | 16.2 kB | Without provenance | Details for clarify_assets-0.0.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clarify_assets-0.0.10-py3-none-any.whl | Python 3 | none | any | Details for clarify_assets-0.0.10-py3-none-any.whl |
Total release size: 33.9 kB
Release files / clarify_assets-0.0.10.tar.gz
| Download URL | clarify_assets-0.0.10.tar.gz |
|---|---|
| Size | 16.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c954b714bdbc09607d3b557dda6866bf3919ea30e7220e4bc25c3fb1c283973c
|
|
BLAKE2b-256 checksum How to use checksums |
17511241660bd8f2fe858dde5c9abd38a00876394fe1a1449fc4b947e6de1a50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / clarify_assets-0.0.10-py3-none-any.whl
| Download URL | clarify_assets-0.0.10-py3-none-any.whl |
|---|---|
| Size | 17.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee287d9de38e0b288a1c80af385e2672278658cc62de394fbfd70605cde8a2fe
|
|
BLAKE2b-256 checksum How to use checksums |
d99e4c5e7e38764b4671a8460e3b403603b82e8567c1a1285786837d4c57209d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Security for clarify-assets 0.0.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.