golemfactory / yapapi

Python high-level API for Golem.
https://yapapi.readthedocs.io/en/stable/
GNU Lesser General Public License v3.0
48 stars 23 forks source link

manifest creation helper #1090

Closed shadeofblue closed 1 year ago

shadeofblue commented 1 year ago

Add helper API for manifests,

Based on the schema described in GAP-4: https://github.com/golemfactory/golem-architecture/blob/master/gaps/gap-4_comp_manifest/gap-4_comp_manifest.md and GAP-5 https://github.com/golemfactory/golem-architecture/blob/master/gaps/gap-5_payload_manifest/gap-5_payload_manifest.md

implement a Manifest class that:

manifest = Manifest(image_hash="sha3:05270a8a938ff5f5e30b0e61bc983a8c3e286c5cd414a32e1a077657", properties={"net.inet.out.urls": ["http://bor.golem.network"]})

json.dumps(manifest)

{
  "version": "0.1.0",
  "createdAt": "2022-12-01T00:00:00.000000Z",
  "expiresAt": "2100-01-01T00:00:00.000000Z",
  "payload": [
    {
      "platform": {
        "arch": "x86_64",
        "os": "linux"
      },
      "urls": [
        "http://girepo.dev.golem.network:8000/docker-gas_scanner_backend_image-latest-91c471517a.gvmi"
      ],
      "hash": "sha3:05270a8a938ff5f5e30b0e61bc983a8c3e286c5cd414a32e1a077657"
    }
  ],
  "compManifest": {
    "version": "0.1.0",
    "script": {
      "commands": [
        "run .*"
      ],
      "match": "regex"
    },
    "net": {
      "inet": {
        "out": {
          "protocols": [
            "http"
          ],
          "urls": [
            "http://bor.golem.network"
          ]
        }
      }
    }
  }
}
shadeofblue commented 1 year ago

@approxit

the defaults to be used:

{
    "version": "",
    "createdAt": [ CURRENT DATE TIME ],
    "expiresAt": "2100-01-01T00:01:00.000000Z",
    "payload": [
      {
        "platform": {
          "arch": "x86_64",
          "os": "linux"
        },
        "urls": [ BASED ON THE RESOLVED VALUE FROM THE HASH - or through a directly provided value],
        "hash": [ (for now) MUST BE PROVIDED BY THE USER, may change when we switch to using tags ] 
      }
    ],
    "compManifest": {
      "version": "",

[ only "run" allowed by default, user may, of course override this ] 

      "script": {
        "commands": [
          "run .*",
        ],
        "match": "regex"
      },

[ "net" section not included by default - must be constructed when a user passes a list of URLs] 

    }
}
approxit commented 1 year ago

json schema https://github.com/golemfactory/yagna-docs/blob/master/requestor-tutorials/vm-runtime/computation-payload-manifest.schema.json