Skip to content

How to connect with minio-driver? #199

@MBueschelberger

Description

@MBueschelberger

I am currently running into the issue, that I am not able to connect with dlite to an Minio-instance through the oteapi plugin, but I am actually successful if I use dlite directly.

Here is my docker-compose:

version: "3.7"

services:

  ote_api:
    image: ghcr.io/emmc-asbl/oteapi:latest
    environment:
      OTEAPI_REDIS_DB: 2
      OTEAPI_REDIS_TYPE: redis
      OTEAPI_REDIS_HOST: redis
      OTEAPI_REDIS_PORT: 6379
      OTEAPI_prefix: "${OTEAPI_prefix:-/api/v1}"
      OTEAPI_PLUGIN_PACKAGES: "oteapi-dlite==v0.1.4"
    depends_on:
      - redis
    entrypoint: "./entrypoint.sh --reload --log-level debug"
    networks:
      - otenet

  minio:
    image: quay.io/minio/minio
    ports:
      - 9000
    environment:
      MINIO_ROOT_USER: otadmin
      MINIO_ROOT_PASSWORD: otadmin123
    volumes:
      - ./minio-data:/data
    command: server /data
    networks:
      - otenet

  redis:
    image: redis:latest
    networks:
      - otenet

networks:
  otenet:
    driver: bridge

This is my test-instance:

{ "d71531a5-a6a4-4252-abef-8c2fdf89c416": {
    "meta": "http://www.ontotrans.eu/0.1/inputEntity",
    "dimensions": {},
    "properties": {
      "blooming_duration": 150,
      "blooming_total_passes": 10,
      "c": 0.05,
      "flitzer_duration": 70,
      "mn": 0.8,
      "pyro_bp2_temp_max": 1150,
      "qst_duration": 60,
      "qst_entry_temp_estimate": 900,
      "qst_flow_rate_total": 700,
      "qst_water_temp_entry": 30,
      "tandem_duration": 300,
      "v": 0.01
    }
  }
}

First of all, I tried to store the the instance with the driver directly:

import dlite
from pathlib import Path

thisdir = Path(__file__).resolve().parent

dlite.storage_path.append(thisdir)

access_key = "otadmin"
secret_key = "otadmin123"
instance_key = "d71531a5-a6a4-4252-abef-8c2fdf89c416"

url = f"minio://minio:9000?access_key={access_key};secret_key={secret_key};secure=False"

instance = dlite.get_instance(instance_key)

with dlite.Storage(url) as s:
    s.save(instance.meta)
    s.save(instance)

This was obviously successful, since I can fetch the instance again with this id:

import dlite

access_key = "otadmin"
secret_key = "otadmin123"
instance_key = "d71531a5-a6a4-4252-abef-8c2fdf89c416"

url = f"minio://minio:9000?access_key={access_key};secret_key={secret_key};secure=False"

dlite.storage_path.append(url)
instance = dlite.get_instance(instance_key)

print(instance)

The printed instance looks like this (as expected):

{
  "d71531a5-a6a4-4252-abef-8c2fdf89c416":  {
    "meta": "http://www.ontotrans.eu/0.1/inputEntity",
    "dimensions": {
    },
    "properties": {
      "blooming_duration": 150,
      "blooming_total_passes": 10,
      "c": 0.05,
      "flitzer_duration": 70,
      "mn": 0.8,
      "pyro_bp2_temp_max": 1150,
      "qst_duration": 60,
      "qst_entry_temp_estimate": 900,
      "qst_flow_rate_total": 700,
      "qst_water_temp_entry": 30,
      "tandem_duration": 300,
      "v": 0.01
    }
  }
}

However, when I try to fetch the instance through oteapi-dlite with following config...

from oteapi_dlite.strategies.parse import DLiteParseStrategy, DLiteParseResourceConfig

access_key = "otadmin"
secret_key = "otadmin123"
instance_key = "d71531a5-a6a4-4252-abef-8c2fdf89c416"

session = {}
config = {
    "downloadUrl": "http://minio:9000", # does not seem to be needed here?
    "mediaType": "minio", # also does not seem to explicity be needed here?
    "configuration": {
        "driver": "minio", 
        "location": "minio:9000",
        "id": instance_key,
        "options": f"access_key={access_key};secret_key={secret_key};secure=False",
        "label": "input_entity_definition"
    }
}

config = DLiteParseResourceConfig(**config)

parse = DLiteParseStrategy(parse_config=config)
session = parse.get(session)
print(session)

... I get the following traceback:

** DLiteOtherError: cannot find metadata 'http://www.ontotrans.eu/0.1/inputEntity' when loading 'd71531a5-a6a4-4252-abef-8c2fdf89c416' - please add the right storage to DLITE_STORAGES and try again
** DLiteOtherError: cannot find metadata 'http://www.ontotrans.eu/0.1/inputEntity' when loading 'd71531a5-a6a4-4252-abef-8c2fdf89c416' - please add the right storage to DLITE_STORAGES and try again
 - DLiteOtherError: calling load() in Python plugin 'minio'
   To see error messages from Python storages, please rerun with the
   DLITE_PYDEBUG environment variable set.
   For example: `export DLITE_PYDEBUG=`

: DLiteUnknownError: DLiteOtherError: cannot find metadata 'http://www.ontotrans.eu/0.1/inputEntity' when loading 'd71531a5-a6a4-4252-abef-8c2fdf89c416' - please add the right storage to DLITE_STORAGES and try again
Traceback (most recent call last):
  File "/shared/store-minio-ote.py", line 26, in <module>
    session = parse.get(session)
  File "/usr/local/lib/python3.9/site-packages/oteapi_dlite/strategies/parse.py", line 107, in get
    inst = dlite.Instance.from_location(
  File "/usr/local/lib/python3.9/site-packages/dlite/dlite.py", line 1370, in from_location
    return Instance(
  File "/usr/local/lib/python3.9/site-packages/dlite/dlite.py", line 1282, in __init__
    raise _dlite.DLiteError(f"cannot initiate dlite.Instance")
dlite.DLiteError: cannot initiate dlite.Instance

Since I actually saved the metadata in the script shown previously, I am not sure why the plugin is not able to fetch the instance with through the given configuration.

Obviously, the arguments in the options-string in the driver-config need to be ;-separated instead of ,-separated, as it is written in the attribute description.

Additionally, it would be great if the plugin would use the user/password attributes of the ResourceConfig (inherited from the SecretConfig) in the oteapi for later passing it to the access_key and secret_key in the options-string of the driver.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions