props

package
v0.0.0-...-d58e437 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SCHEME      = "golem.com.scheme"
	PRICE_MODEL = "golem.com.pricing.model"

	LINEAR_COEFFS  = "golem.com.pricing.model.linear.coeffs"
	DEFINED_USAGES = "golem.com.usage.vector"
)
View Source
const (
	ComScheme     = "Scheme"
	ComPriceModel = "PriceModel"
)
View Source
const (
	INF_MEM       = "golem.inf.mem.gib"
	INF_STORAGE   = "golem.inf.storage.gib"
	INF_CORES     = "golem.inf.cpu.cores"
	TRANSFER_CAPS = "golem.activity.caps.transfer.protocol"
)
View Source
const (
	InfBaseMem       = "Mem"
	InfBaseRuntime   = "Runtime"
	InfBaseStorage   = "Storage"
	InfBaseTransfers = "Transfers"
)
View Source
const (
	NodeInfoName      = "Name"
	NodeInfoSubnetTag = "SubnetTag"
)
View Source
const (
	ActivityCostCap       = "CostCap"
	ActivityCostWarning   = "CostWarning"
	ActivityTimeoutSecs   = "TimeoutSecs"
	ActivityExpiration    = "Expiration"
	ActivityMultiActivity = "MultiActivity"
)
View Source
const (
	ExeUnitRequestPackageUrl = "PackageUrl"
)
View Source
const (
	InfVmCores = "Cores"
)
View Source
const (
	VMRequestPackageFormat = "PackageFormat"
)

Variables

View Source
var ActivityKeys = (&Activity{}).Keys()
View Source
var InfVmKeys = (&InfVm{}).Keys()
View Source
var NodeInfoKeys = (&NodeInfo{}).Keys()

Functions

func FromProperties

func FromProperties(props Props, model Model) error

Types

type Activity

type Activity struct {
	Model
	/* CostCap sets a Hard cap on total cost of the Activity (regardless of the usage vector or
	pricing function). The Provider is entitled to 'kill' an Activity which exceeds the
	capped cost amount indicated by Requestor.
	*/
	CostCap decimal.Decimal `field:"optional"`
	/*CostWarning sets a Soft cap on total cost of the Activity (regardless of the usage vector or
	pricing function). When the cost_warning amount is reached for the Activity,
	the Provider is expected to send a Debit Note to the Requestor, indicating
	the current amount due
	*/
	CostWarning decimal.Decimal `field:"optional"`
	/* TimeoutSecs is a timeout value for batch computation (eg. used for container-based batch
	processes). This property allows to set the timeout to be applied by the Provider
	when running a batch computation: the Requestor expects the Activity to take
	no longer than the specified timeout value - which implies that
	eg. the golem.usage.duration_sec counter shall not exceed the specified
	timeout value.
	*/
	TimeoutSecs float32   `field:"optional"`
	Expiration  time.Time `field:"optional"`
	// MultiActivity means whether client supports multi_activity (executing more than one activity per agreement).
	MultiActivity bool `field:"optional"`
}

Activity-related Properties.

func (*Activity) Keys

func (a *Activity) Keys() map[string]string

type BillingScheme

type BillingScheme string

BillingScheme enum.

const (
	BillingSchemePAYU BillingScheme = "payu"
)

func (BillingScheme) Validate

func (e BillingScheme) Validate() error

type Com

type Com struct {
	Scheme     BillingScheme `field:"optional"`
	PriceModel PriceModel    `field:"optional"`
}

func (*Com) Keys

func (c *Com) Keys() map[string]string

type ComLinear

type ComLinear struct {
	Com
	FixedPrice float32
	PriceFor   map[Counter]float32
}

func (*ComLinear) CustomMapping

func (cl *ComLinear) CustomMapping(props Props) error

func (*ComLinear) Keys

func (cl *ComLinear) Keys() map[string]string

type Counter

type Counter string
const (
	CounterTIME    Counter = "golem.usage.duration_sec"
	CounterCPU     Counter = "golem.usage.cpu_sec"
	CounterSTORAGE Counter = "golem.usage.storage_gib"
	CounterMAXMEM  Counter = "golem.usage.gib"
	CounterUNKNOWN Counter = ""
)

func (Counter) Validate

func (e Counter) Validate() error

type DemandBuilder

type DemandBuilder struct {
	// contains filtered or unexported fields
}

func NewDemandBuilder

func NewDemandBuilder() *DemandBuilder

Builds a dictionary of properties and constraints from high-level models.

The dictionary represents a Demand object, which is later matched by the new Golem's market implementation against Offers coming from providers to find those providers who can satisfy the requestor's demand.

example usage:

```python >>> import yapapi >>> from yapapi import properties as yp >>> from yapapi.props.builder import DemandBuilder >>> from datetime import datetime, timezone >>> builder = DemandBuilder() >>> builder.add(yp.NodeInfo(name="a node", subnet_tag="testnet")) >>> builder.add(yp.Activity(expiration=datetime.now(timezone.utc))) >>> builder.__repr__ >>> print(builder) {'properties':

	{'golem.node.id.name': 'a node',
	 'golem.node.debug.subnet': 'testnet',
	 'golem.srv.comp.expiration': 1601655628772},
 'constraints': []}

```

func (*DemandBuilder) Add

func (db *DemandBuilder) Add(m Model)

func (*DemandBuilder) Constraints

func (db *DemandBuilder) Constraints() string

func (*DemandBuilder) Ensure

func (db *DemandBuilder) Ensure(constraint string)

func (*DemandBuilder) Properties

func (db *DemandBuilder) Properties() map[string]interface{}

func (*DemandBuilder) String

func (db *DemandBuilder) String() string

type ExeUnitRequest

type ExeUnitRequest struct {
	PackageUrl string
}

func (*ExeUnitRequest) Keys

func (eur *ExeUnitRequest) Keys() map[string]string

type InfBase

type InfBase struct {
	Mem       float32
	Runtime   RuntimeType
	Storage   float32  `field:"optional"`
	Transfers []string `field:"optional"`
}

func (*InfBase) Keys

func (ib *InfBase) Keys() map[string]string

type InfVm

type InfVm struct {
	InfBase
	Cores int
}

func (*InfVm) CustomMapping

func (iv *InfVm) CustomMapping(props Props)

func (*InfVm) Keys

func (iv *InfVm) Keys() map[string]string

type InvalidPropertiesError

type InvalidPropertiesError struct {
	// contains filtered or unexported fields
}

InvalidPropertiesError will be raised by `NewFromProperties(properties)` when given invalid `properties`.

func (InvalidPropertiesError) Error

func (i InvalidPropertiesError) Error() string

type Model

type Model interface {
	/*
		:return: a mapping between the model's field names and the property keys

		example:
		“`python
		>>> import dataclasses
		>>> import typing
		>>> from yapapi.properties.base import Model
		>>> @dataclasses.dataclass
		... class NodeInfo(Model):
		...     name: typing.Optional[str] = \
		...     dataclasses.field(default=None, metadata={"key": "golem.node.id.name"})
		...
		>>> NodeInfo.keys().name
		'golem.node.id.name'
		“`
	*/
	Keys() map[string]string
	CustomMapping(props Props) error
}

Model is the base struct from which all property models embed.

Provides helper methods to load the property model data from a dictionary and to get a mapping of all the keys available in the given model.

type NodeInfo

type NodeInfo struct {
	Model
	// Name is the human-readable name of the Golem node.
	Name string `field:"optional"`
	// SubnetTag is the the name of the subnet within which the Demands and Offers are matched.
	SubnetTag string `field:"optional"`
}

NodeInfo holds the properties describing the information regarding the node.

func (*NodeInfo) Keys

func (ni *NodeInfo) Keys() map[string]string

type PriceModel

type PriceModel string
const (
	PriceModelLINEAR PriceModel = "linear"
)

func (PriceModel) Validate

func (e PriceModel) Validate() error

type Props

type Props map[string]interface{}

TODO: we can use

type RuntimeType

type RuntimeType string

BillingScheme enum.

const (
	RuntimeTypeUNKNOWN    RuntimeType = ""
	RuntimeTypeWASMTIME   RuntimeType = "wasmtime"
	RuntimeTypeEMSCRIPTEN RuntimeType = "emscripten"
	RuntimeTypeVM         RuntimeType = "vm"
)

func (RuntimeType) Validate

func (e RuntimeType) Validate() error

type VMRequest

type VMRequest struct {
	ExeUnitRequest
	PackageFormat VmPackageFormat
}

func (*VMRequest) CustomMapping

func (vmr *VMRequest) CustomMapping(props Props) error

func (*VMRequest) Keys

func (vmr *VMRequest) Keys() map[string]string

type VmPackageFormat

type VmPackageFormat string
const (
	VmPackageFormatUNKNOWN       VmPackageFormat = ""
	VmPackageFormatGVMKIT_SQUASH VmPackageFormat = "gvmkit-squash"
)

func (VmPackageFormat) Validate

func (e VmPackageFormat) Validate() error

type WasmInterface

type WasmInterface string
const (
	WasmInterfaceWASI_0         WasmInterface = "0"
	WasmInterfaceWASI_0preview1 WasmInterface = "0preview1"
)

func (WasmInterface) Validate

func (e WasmInterface) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL