Skip to main content

No project description provided

Project description

Dwave SONA Core

迪威智能 SONA 服務專用核心開發套件

安裝與使用

開發環境需求

  • Python 3.8 或更新版本
  • poetry
  • ffmpeg

安裝與使用

  1. 環境建構
$ pip install poetry
  1. 下載與安裝
$ export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring
$ poetry add git+ssh://git@github.com/DeepWaveInc/dwave-sona-core.git
  1. 撰寫 Inferencer 模組
from typing import Dict, List

from loguru import logger
from pydantic import BaseModel, Field
from sona.core.inferencer import InferencerBase
from sona.core.messages import File, Result


class InputParamSchema(BaseModel):
    param1: int = Field(42, description="this is the value of param1")
    param2: str = Field("43", description="this is the value of param2")


class InputFilesSchema(BaseModel):
    origin: str = Field("data/test.mp3", description="this is the value of origin")


class SimpleInferencer(InferencerBase):
    name = "mock"
    description = "This is a simple inferencer"
    input_params_schema = InputParamSchema()
    input_files_schema = InputFilesSchema()

    def on_load(self) -> None:
        logger.info(f"Download {self.__class__.__name__} models...")

    def inference(self, params: Dict, files: List[File]) -> Result:
        logger.info(f"Get params {params}")
        logger.info(f"Get files {files}")
        return Result(
            files=[File(label="output", path=files[0].path)],
            data={"output_key": "output_val"},
        )


if __name__ == "__main__":
    inferencer = SimpleInferencer()
    inferencer.cmd()
  1. 測試指令
$ python simple.py --help
Usage: simple.py [OPTIONS] <filepath:origin>

  This is a simple inferencer

Options:
  --param2 <string>   this is the value of param2
  --param1 <integer>  this is the value of param1
  --help              Show this message and exit.
$ python tests/simple.py tests/simple.py
2023-10-17 02:18:41.702 | INFO     | __main__:on_load:25 - Download SimpleInferencer models...
2023-10-17 02:18:41.702 | INFO     | __main__:inference:28 - Get params {'param2': '43', 'param1': 42}
2023-10-17 02:18:41.703 | INFO     | __main__:inference:29 - Get files [File(label='origin', path='tests/simple.py', metadata={})]
{"files":[{"label":"output","path":"tests/simple.py","metadata":{}}],"data":{"output_key":"output_val"}}

Project details


Release history Release notifications | RSS feed

This version

1.6.9

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dwave_sona_core-1.6.9.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dwave_sona_core-1.6.9-py3-none-any.whl (45.6 kB view details)

Uploaded Python 3

File details

Details for the file dwave_sona_core-1.6.9.tar.gz.

File metadata

  • Download URL: dwave_sona_core-1.6.9.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.18 Darwin/25.2.0

File hashes

Hashes for dwave_sona_core-1.6.9.tar.gz
Algorithm Hash digest
SHA256 63b250f725c83f057a975aef6c634b9b73a6d61217693f15f4d1bc9bcdd4f2fc
MD5 4d95866acf1f4582bf164f072e2ae0ef
BLAKE2b-256 f06edb3b7b7394b17bb6cad9b85f8ffd26104dbcca5fd3bb98946f9aa0e3c493

See more details on using hashes here.

File details

Details for the file dwave_sona_core-1.6.9-py3-none-any.whl.

File metadata

  • Download URL: dwave_sona_core-1.6.9-py3-none-any.whl
  • Upload date:
  • Size: 45.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.18 Darwin/25.2.0

File hashes

Hashes for dwave_sona_core-1.6.9-py3-none-any.whl
Algorithm Hash digest
SHA256 587542e1bb25544df278ca2a6fe7b364a832c6cd544c748b00ab0785421a3f2a
MD5 7919b43d9ded26ba0a38194ed66e043e
BLAKE2b-256 68f42508dbb54f01be78757f2d1fff8236c1b226fcac747f496a6062ce744186

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page