Documentation ¶
Index ¶
- Constants
- Variables
- func FromProperties(props Props, model Model) error
- type Activity
- type BillingScheme
- type Com
- type ComLinear
- type Counter
- type DemandBuilder
- type ExeUnitRequest
- type InfBase
- type InfVm
- type InvalidPropertiesError
- type Model
- type NodeInfo
- type PriceModel
- type Props
- type RuntimeType
- type VMRequest
- type VmPackageFormat
- type WasmInterface
Constants ¶
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" )
const ( ComScheme = "Scheme" ComPriceModel = "PriceModel" )
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" )
const ( InfBaseMem = "Mem" InfBaseRuntime = "Runtime" InfBaseStorage = "Storage" InfBaseTransfers = "Transfers" )
const ( NodeInfoName = "Name" NodeInfoSubnetTag = "SubnetTag" )
const ( ActivityCostCap = "CostCap" ActivityCostWarning = "CostWarning" ActivityTimeoutSecs = "TimeoutSecs" ActivityExpiration = "Expiration" ActivityMultiActivity = "MultiActivity" )
const (
ExeUnitRequestPackageUrl = "PackageUrl"
)
const (
InfVmCores = "Cores"
)
const (
VMRequestPackageFormat = "PackageFormat"
)
Variables ¶
var ActivityKeys = (&Activity{}).Keys()
var InfVmKeys = (&InfVm{}).Keys()
var NodeInfoKeys = (&NodeInfo{}).Keys()
Functions ¶
func FromProperties ¶
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.
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"` }
type ComLinear ¶
func (*ComLinear) CustomMapping ¶
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"` }
type InfVm ¶
func (*InfVm) CustomMapping ¶
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.
type PriceModel ¶
type PriceModel string
const (
PriceModelLINEAR PriceModel = "linear"
)
func (PriceModel) Validate ¶
func (e PriceModel) Validate() error
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 ¶
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