Python dataclasses for CGMES 3.0.0
Project description
cgmes-python
Python dataclasses for CGMES 3 + rdf schema description + SHACL files.
Library usage
From Pypi.org, 2 packages are available:
- https://nexus.appx.cloud/#browse/browse:uno-pypi:pycgmes
- https://nexus.appx.cloud/#browse/browse:uno-pypi:pycgmes-shacl
They can be installed by pip once https://nexus.appx.cloud/repository/uno-pypi/simple
is added as pip extra url or Poetry dependency.
Custom attributes
Apparent class
If you need to add your own attributes (example: cable colour), you can do that by subclassing the relevant class.
If this is a leaf node (for instance ACLineSegment
), it "just works". If you want to add an extra attribute to a
class higher in the hierarchy (for instance Equipment
) there is a lot more work to do.
By default, an attribute is fully qualified. bch
in ACLineSegment
will appear as ACLineSegment.bch
in the serialisation.
For a custom attribute, you might not want to see ACLineSegmentCustom.bch
. To prevent this, you can override the apparent_name
of your custom class:
from pydantic.dataclasses import dataclass
from pycgmes.resources import ACLineSegment
from pycgmes.resources.Base import DataclassConfig
@dataclass(config=DataclassConfig)
class ACLineSegmentCustom(ACLineSegment):
@classmethod
def apparent_name(cls):
return "ACLineSegment"
Namespace
In the serialisation, the namespace of all attributes is cim
("http://iec.ch/TC57/2013/CIM-schema-cim16#"
) by default.
The serialisation is not done by PyCGMES (yet), but if you want a custom namespace for an attribute,
you can give a hint to the serialiser by adding some metadata to your custom attributes:
from pydantic.dataclasses import dataclass
from pydantic import Field
from pycgmes.resources import ACLineSegment
from pycgmes.resources.Base import DataclassConfig, Profile
@dataclass(config=DataclassConfig)
class ACLineSegmentCustom(ACLineSegment):
colour: str = Field(
default="Red",
in_profiles=[
Profile.EQ,
],
namespace="custom",
)
@classmethod
def apparent_name(cls):
return "ACLineSegment"
It will be given when cgmes_attributes_in_profile()
is called.
Content
Schemas v3
schemas are rdf definitions of CGMES. They are used once, to generate dataclasses, and can then happily be forgotten.
They are available on the ENTSO-E site. Look for CGMES Conformity Assessment Scheme v3 then Application Profiles v3.0.1
Older versions could be found on the ENTSO-E site.
Shacl files
Shapes constraint Language is used for validation of the actual content of the CGMES files, not just XML validation. They can be found in shacl. This is the new validation standard. OCL is referenced, specially with older versions, but Entsoe is moving away from it.
To use them, there is another package pycmges-shacl
, built from this repo as well.
V3 source zip
From Entsoe, in data. This is one small-ish zip file, containing a bit more than just the shacl and rdfs files (those extracted and mentioned above) but is usually not needed.
Dataclasses
Generated from the modernpython serialisation of cimgen.
Library build, CI, CD...
CI
The CI happens in GitHub actions.
The standard black/mypy/autoflake/isort/pylint/ruff/mypy are run there, via scons.
CD
Deployment happens to pypi.org, via the standard poetry commands poetry build
, poetry publish
.
License
This project is licensed under the Apache 2.0 license - see LICENSE for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pycgmes-1.0.0.tar.gz
.
File metadata
- Download URL: pycgmes-1.0.0.tar.gz
- Upload date:
- Size: 179.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d59d3ee1ba37bef46ba94127dca0100743c8348e8dd1e25a35fd58afaba32e49 |
|
MD5 | cc88e1756659efa254ef2776b90e931f |
|
BLAKE2b-256 | 4e638ac70f747faf49aaedef3a33c992dd18ad18a6a6b44f6f8e9f60c3e22394 |
Provenance
File details
Details for the file pycgmes-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: pycgmes-1.0.0-py3-none-any.whl
- Upload date:
- Size: 543.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Linux/5.15.0-1041-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9b0a940855b55a13216e9333d2366100232d197b02659affd668544e029bef0 |
|
MD5 | 448c7a2b94a278bb4aca68ed89079487 |
|
BLAKE2b-256 | 85899133441f942e220c6b2fa726c08f60d19a5409e32202d100fedd3d94eb7e |