opdm-api


Nameopdm-api JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/Haigutus/OPDM
SummaryENTSO-E OPDM client SOAP API implementation in python
upload_time2024-10-28 00:18:03
maintainerNone
docs_urlNone
authorKristjan Vilgo
requires_pythonNone
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # OPDM
Python implementation of OPDM SOAP API. OPDM is used to exchange Electrical Grid Models between ENTSO-E TSO-s and RSC-s

Other relevant API-s:
 - [ECP](https://github.com/Haigutus/ECP)
 - [EDX](https://github.com/Haigutus/EDX)

# Installation

    pip install opdm-api

or

    pip install --user opdm-api

or 

    python -m pip install --user opdm-api


# Usage

## Initialise
    import OPDM

    service = OPDM.Client("https://opdm.elering.sise:8443", username="user", password="pass")

## Upload File
### Upload a file
    response = service.publication_request(file_path_or_objet)

### Upload all files in a directory
    import glob
    imort os

    for file_name in glob.glob1(directory_path, "*.zip"):
        service.publication_request(os.path.join(directory_path, file_name))

## Get File Upload/Publication Report
    publication_report = service.get_profile_publication_report(model_ID)

or

    publication_report = service.get_profile_publication_report(filename="uploaded_file_name.zip")

## Subscribe for Model publications
### Get available Publications
    available_publications = service.publication_list()

### Subscribe for BDS
*available publications: BDS, IGM, CGM*

    response = service.publication_subscribe("BDS")

### Subscribe for all IGM-s except RT

    time_horizons = [f"{item:02d}" for item in list(range(1,32))] + ["ID", "1D", "2D", "YR"]
    for time_horizon in time_horizons:
        print(f"Adding subscription for {time_horizon}")
        response = service.publication_subscribe("IGM", subscription_id=f"IGM-{time_horizon}", metadata_dict={'pmd:timeHorizon': time_horizon})
        print(response)

## Cancel Subscription
    response = service.publication_cancel_subscription(subscription_id)

## Query Data
### Model
*Model consists of multiple files*

    response = service.query_object(object_type = "IGM", metadata_dict = {'pmd:scenarioDate': '2019-07-28T00:30:00', 'pmd:timeHorizon': '1D'})

### File

    response = service.query_profile('pmd:timeHorizon': '1D', 'pmd:cgmesProfile': 'SV'})

### Create nice table of returned Query responses

    import pandas

    pandas.set_option("display.max_rows", 12)
    pandas.set_option("display.max_columns", 10)
    pandas.set_option("display.width", 1500)
    pandas.set_option('display.max_colwidth', -1)

    print(pandas.DataFrame(response['sm:QueryResult']['sm:part'][1:]))


## Download a File
### Download to OPDM Client and return local path to the file
    response = service.get_content(file_UUID)
    print(response['sm:GetContentResult']['sm:part'][1]['opdm:Profile']['opde:Content'])

### Download and Save file
    import base64
    response = service.get_content(file_UUID, return_payload=True)
    with open(f"{file_UUID}.zip", 'wb') as cgmes_file:
        report_file.write(base64.b64decode(response['sm:GetContentResult']['sm:part'][1]['opdm:Profile']['opde:Content'].encode()))

## Manage Rulesets

### List available Ruleset
    service.list_available_rulesets()

### Install Ruleset
    service.install_rulesets(version="2.0.122")

### Get installed Ruleset version
    service.get_installed_ruleset_version()

### Reset Ruleset
    service.reset_ruleset()


## [Examples](https://github.com/Haigutus/OPDM/tree/main/examples)
 - [Download latest Boundary](https://github.com/Haigutus/OPDM/blob/main/examples/download_latest_BDS.py)
 - [Download all Boundaries](https://github.com/Haigutus/OPDM/blob/main/examples/download_all_BDS.py)
 - [Install latest Rule Set](https://github.com/Haigutus/OPDM/blob/main/examples/install_latest_RSL.py)
 - [Upload IGM](https://github.com/Haigutus/OPDM/blob/main/examples/upload_IGMs.py)








            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Haigutus/OPDM",
    "name": "opdm-api",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Kristjan Vilgo",
    "author_email": "kristjan.vilgo@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/ac/3a/53fb6626b335a5d44aeb5be67c11c650446350f79f2e3fa6e058c488bf8c/opdm-api-0.1.1.tar.gz",
    "platform": null,
    "description": "# OPDM\nPython implementation of OPDM SOAP API. OPDM is used to exchange Electrical Grid Models between ENTSO-E TSO-s and RSC-s\n\nOther relevant API-s:\n - [ECP](https://github.com/Haigutus/ECP)\n - [EDX](https://github.com/Haigutus/EDX)\n\n# Installation\n\n    pip install opdm-api\n\nor\n\n    pip install --user opdm-api\n\nor \n\n    python -m pip install --user opdm-api\n\n\n# Usage\n\n## Initialise\n    import OPDM\n\n    service = OPDM.Client(\"https://opdm.elering.sise:8443\", username=\"user\", password=\"pass\")\n\n## Upload File\n### Upload a file\n    response = service.publication_request(file_path_or_objet)\n\n### Upload all files in a directory\n    import glob\n    imort os\n\n    for file_name in glob.glob1(directory_path, \"*.zip\"):\n        service.publication_request(os.path.join(directory_path, file_name))\n\n## Get File Upload/Publication Report\n    publication_report = service.get_profile_publication_report(model_ID)\n\nor\n\n    publication_report = service.get_profile_publication_report(filename=\"uploaded_file_name.zip\")\n\n## Subscribe for Model publications\n### Get available Publications\n    available_publications = service.publication_list()\n\n### Subscribe for BDS\n*available publications: BDS, IGM, CGM*\n\n    response = service.publication_subscribe(\"BDS\")\n\n### Subscribe for all IGM-s except RT\n\n    time_horizons = [f\"{item:02d}\" for item in list(range(1,32))] + [\"ID\", \"1D\", \"2D\", \"YR\"]\n    for time_horizon in time_horizons:\n        print(f\"Adding subscription for {time_horizon}\")\n        response = service.publication_subscribe(\"IGM\", subscription_id=f\"IGM-{time_horizon}\", metadata_dict={'pmd:timeHorizon': time_horizon})\n        print(response)\n\n## Cancel Subscription\n    response = service.publication_cancel_subscription(subscription_id)\n\n## Query Data\n### Model\n*Model consists of multiple files*\n\n    response = service.query_object(object_type = \"IGM\", metadata_dict = {'pmd:scenarioDate': '2019-07-28T00:30:00', 'pmd:timeHorizon': '1D'})\n\n### File\n\n    response = service.query_profile('pmd:timeHorizon': '1D', 'pmd:cgmesProfile': 'SV'})\n\n### Create nice table of returned Query responses\n\n    import pandas\n\n    pandas.set_option(\"display.max_rows\", 12)\n    pandas.set_option(\"display.max_columns\", 10)\n    pandas.set_option(\"display.width\", 1500)\n    pandas.set_option('display.max_colwidth', -1)\n\n    print(pandas.DataFrame(response['sm:QueryResult']['sm:part'][1:]))\n\n\n## Download a File\n### Download to OPDM Client and return local path to the file\n    response = service.get_content(file_UUID)\n    print(response['sm:GetContentResult']['sm:part'][1]['opdm:Profile']['opde:Content'])\n\n### Download and Save file\n    import base64\n    response = service.get_content(file_UUID, return_payload=True)\n    with open(f\"{file_UUID}.zip\", 'wb') as cgmes_file:\n        report_file.write(base64.b64decode(response['sm:GetContentResult']['sm:part'][1]['opdm:Profile']['opde:Content'].encode()))\n\n## Manage Rulesets\n\n### List available Ruleset\n    service.list_available_rulesets()\n\n### Install Ruleset\n    service.install_rulesets(version=\"2.0.122\")\n\n### Get installed Ruleset version\n    service.get_installed_ruleset_version()\n\n### Reset Ruleset\n    service.reset_ruleset()\n\n\n## [Examples](https://github.com/Haigutus/OPDM/tree/main/examples)\n - [Download latest Boundary](https://github.com/Haigutus/OPDM/blob/main/examples/download_latest_BDS.py)\n - [Download all Boundaries](https://github.com/Haigutus/OPDM/blob/main/examples/download_all_BDS.py)\n - [Install latest Rule Set](https://github.com/Haigutus/OPDM/blob/main/examples/install_latest_RSL.py)\n - [Upload IGM](https://github.com/Haigutus/OPDM/blob/main/examples/upload_IGMs.py)\n\n\n\n\n\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "ENTSO-E OPDM client SOAP API implementation in python",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/Haigutus/OPDM"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7f205adcc8708ef2a2b046a4d81afe87a100215c0fe50353deefd8d25e1c2c14",
                "md5": "a15ed54c1991e4771637cc72afc49098",
                "sha256": "177233ef1161c01b7f793bad73f4edbf732f79a5efad3a445324a782e86062c3"
            },
            "downloads": -1,
            "filename": "opdm_api-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a15ed54c1991e4771637cc72afc49098",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 11470,
            "upload_time": "2024-10-28T00:18:02",
            "upload_time_iso_8601": "2024-10-28T00:18:02.034967Z",
            "url": "https://files.pythonhosted.org/packages/7f/20/5adcc8708ef2a2b046a4d81afe87a100215c0fe50353deefd8d25e1c2c14/opdm_api-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "ac3a53fb6626b335a5d44aeb5be67c11c650446350f79f2e3fa6e058c488bf8c",
                "md5": "38732f43f67e9e614216009650f751aa",
                "sha256": "0b56b9c4bf6d2cd71a20b5571579bcf8125d3321b92bb3ad5a032ea4cf1e923a"
            },
            "downloads": -1,
            "filename": "opdm-api-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "38732f43f67e9e614216009650f751aa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 25694,
            "upload_time": "2024-10-28T00:18:03",
            "upload_time_iso_8601": "2024-10-28T00:18:03.356208Z",
            "url": "https://files.pythonhosted.org/packages/ac/3a/53fb6626b335a5d44aeb5be67c11c650446350f79f2e3fa6e058c488bf8c/opdm-api-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-28 00:18:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Haigutus",
    "github_project": "OPDM",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "opdm-api"
}
        
Elapsed time: 1.09246s