@xyo-network/diviner-forecasting-memory 3.6.0-rc.7 → 3.6.0-rc.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,6 +17,6 @@ export declare class MemoryForecastingDiviner<TParams extends ForecastingDiviner
17
17
  protected get forecastingMethod(): ForecastingMethod;
18
18
  protected get maxTrainingLength(): number;
19
19
  protected get transformer(): PayloadValueTransformer;
20
- protected getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]>;
20
+ protected getPayloadsInWindow(_startTimestamp: number, _stopTimestamp: number): Promise<Payload[]>;
21
21
  }
22
22
  //# sourceMappingURL=MemoryForecastingDiviner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MemoryForecastingDiviner.d.ts","sourceRoot":"","sources":["../../src/MemoryForecastingDiviner.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAA;AACzF,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAA;AACtF,OAAO,KAAK,EACV,oBAAoB,EACpB,4BAA4B,EAC7B,MAAM,+CAA+C,CAAA;AAKtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAA;AAIxG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AAGjE,MAAM,MAAM,wBAAwB,GAAG,OAAO,oBAAoB,GAAG,OAAO,4BAA4B,CAAA;AAaxG,qBAAa,wBAAwB,CACnC,OAAO,SAAS,wBAAwB,GAAG,wBAAwB,CACnE,SAAQ,0BAA0B,CAAC,OAAO,CAAC;IAC3C,gBAAyB,aAAa,EAAE,MAAM,EAAE,CAA2D;IAC3G,gBAAyB,mBAAmB,EAAE,MAAM,CAAiC;IAErF,SAAS,CAAC,MAA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AAC,CAGnG;IAED,IAAI,mBAAmB,IAAI,YAAY,CAEtC;IAED;;OAEG;IACH,SAAS,KAAK,UAAU,WAEvB;IAED,cAAuB,iBAAiB,IAAI,iBAAiB,CAK5D;IAED,SAAS,KAAK,iBAAiB,WAE9B;IAED,cAAuB,WAAW,IAAI,uBAAuB,CAG5D;cAEwB,mBAAmB,CAAC,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;CAkDlH"}
@@ -55,7 +55,7 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
55
55
  const pathExpression = assertEx(this.config.jsonPathExpression, () => "Missing jsonPathExpression in config");
56
56
  return getJsonPathTransformer(pathExpression);
57
57
  }
58
- async getPayloadsInWindow(startTimestamp, stopTimestamp) {
58
+ async getPayloadsInWindow(_startTimestamp, _stopTimestamp) {
59
59
  const addresses = this.config.witnessAddresses;
60
60
  const payload_schemas = [
61
61
  assertEx(this.config.witnessSchema, () => "Missing witnessSchema in config")
@@ -65,7 +65,6 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
65
65
  const bwDiviner = asDivinerInstance((await this.resolve(this.boundWitnessDiviner)).pop(), "Unable to resolve boundWitnessDiviner");
66
66
  const limit = this.batchLimit;
67
67
  const witnessSchema = assertEx(this.config.witnessSchema, () => "Missing witnessSchema in config");
68
- let timestamp = stopTimestamp;
69
68
  let more = true;
70
69
  while (more || payloads.length < this.maxTrainingLength) {
71
70
  const query = {
@@ -76,10 +75,12 @@ var MemoryForecastingDiviner = class _MemoryForecastingDiviner extends AbstractF
76
75
  };
77
76
  const boundWitnesses = (await bwDiviner.divine([
78
77
  query
79
- ])).filter((bw) => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp);
78
+ ])).filter(
79
+ // TODO; Replace with sequence
80
+ // bw => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp,
81
+ (_) => true
82
+ );
80
83
  if (boundWitnesses.length === 0) break;
81
- timestamp = boundWitnesses.map((bw) => bw.$timestamp).filter(exists).reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER);
82
- if (timestamp === Number.MAX_SAFE_INTEGER) break;
83
84
  more = boundWitnesses.length === limit;
84
85
  const hashes = boundWitnesses.map((bw) => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists);
85
86
  if (hashes.length > 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/MemoryForecastingDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport { BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport type { ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport { AbstractForecastingDiviner } from '@xyo-network/diviner-forecasting-abstract'\nimport type {\n arimaForecastingName,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport {\n arimaForecastingMethod,\n seasonalArimaForecastingMethod,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport type { ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { ForecastingDivinerConfigSchema } from '@xyo-network/diviner-forecasting-model'\nimport type { DivinerInstance } from '@xyo-network/diviner-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport type { ModuleFilter } from '@xyo-network/module-model'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n return (x: Payload): number => {\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n}\n\nconst defaultBatchLimit = 1000\nconst defaultMaxTrainingLength = 10_000\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = ForecastingDivinerConfigSchema\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n get boundWitnessDiviner(): ModuleFilter {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured') as ModuleFilter\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected get batchLimit() {\n return this.config.batchLimit ?? defaultBatchLimit\n }\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, () => 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected get maxTrainingLength() {\n return this.config.maxTrainingLength ?? defaultMaxTrainingLength\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, () => 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, () => 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, () => 'Missing witnessSchema in config')\n let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = {\n addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema,\n }\n const boundWitnesses = (await bwDiviner.divine([query])).filter(\n bw => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n timestamp = boundWitnesses\n .map(bw => bw.$timestamp)\n .filter(exists)\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER)\n if (timestamp === Number.MAX_SAFE_INTEGER) break\n\n // Set the more flag to false if there are fewer documents returned than the batch size\n more = boundWitnesses.length === limit\n\n // Get the corresponding payload hashes from the BWs\n const hashes = boundWitnesses.map(bw => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists)\n\n // Get the payloads corresponding to the BW hashes from the archivist\n if (hashes.length > 0) {\n const batchPayloads = (await archivist.get(hashes)).filter(exists)\n payloads.push(...batchPayloads)\n }\n }\n return payloads\n }\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,2BAA2B;AAGpC,SAASC,sCAAsC;AAE/C,SAASC,kCAAkC;AAK3C,SACEC,wBACAC,sCACK;AAEP,SAASC,sCAAsC;AAE/C,SAASC,yBAAyB;AAGlC,OAAOC,cAAc;AAIrB,IAAMC,yBAAyB,wBAACC,mBAAAA;AAC9B,SAAO,CAACC,MAAAA;AACN,UAAMC,MAAMC,SAASC,MAAMH,GAAGD,cAAA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AG,GAClD,uCAAA;AAEF,UAAMC,QAAQ,KAAKrB;AACnB,UAAMY,gBAAgBd,SAAS,KAAKC,OAAOa,eAAe,MAAM,iCAAA;AAChE,QAAIU,YAAYd;AAChB,QAAIe,OAAO;AAIX,WAAOA,QAAQV,SAASW,SAAS,KAAKrB,mBAAmB;AACvD,YAAMsB,QAAyC;QAC7ChB;QAAWY;QAAOV;QAAiBe,QAAQC;MAC7C;AACA,YAAMC,kBAAkB,MAAMX,UAAUY,OAAO;QAACJ;OAAM,GAAGK,OACvDC,CAAAA,OAAMA,GAAGC,cAAcD,GAAGC,cAAczB,kBAAkBwB,GAAGC,cAAcxB,aAAAA;AAE7E,UAAIoB,eAAeJ,WAAW,EAAG;AAGjCF,kBAAYM,eACTK,IAAIF,CAAAA,OAAMA,GAAGC,UAAU,EACvBF,OAAOI,MAAAA,EAEPC,OAAO,CAACC,GAAGC,MAAMC,KAAKC,IAAIH,GAAGC,CAAAA,GAAIG,OAAOC,gBAAgB;AAC3D,UAAInB,cAAckB,OAAOC,iBAAkB;AAG3ClB,aAAOK,eAAeJ,WAAWH;AAGjC,YAAMqB,SAASd,eAAeK,IAAIF,CAAAA,OAAMA,GAAGY,eAAeZ,GAAGpB,gBAAgBiC,QAAQhC,aAAAA,CAAAA,CAAe,EAAEkB,OAAOI,MAAAA;AAG7G,UAAIQ,OAAOlB,SAAS,GAAG;AACrB,cAAMqB,iBAAiB,MAAM/B,UAAUgC,IAAIJ,MAAAA,GAASZ,OAAOI,MAAAA;AAC3DrB,iBAASkC,KAAI,GAAIF,aAAAA;MACnB;IACF;AACA,WAAOhC;EACT;AACF;","names":["assertEx","exists","asArchivistInstance","BoundWitnessDivinerQuerySchema","AbstractForecastingDiviner","arimaForecastingMethod","seasonalArimaForecastingMethod","ForecastingDivinerConfigSchema","asDivinerInstance","jsonpath","getJsonPathTransformer","pathExpression","x","ret","jsonpath","value","Error","defaultBatchLimit","defaultMaxTrainingLength","MemoryForecastingDiviner","AbstractForecastingDiviner","configSchemas","ForecastingDivinerConfigSchema","defaultConfigSchema","forecastingMethodDict","arimaForecasting","arimaForecastingMethod","seasonalArimaForecasting","seasonalArimaForecastingMethod","boundWitnessDiviner","assertEx","config","batchLimit","forecastingMethod","forecastingMethodName","maxTrainingLength","transformer","jsonPathExpression","getPayloadsInWindow","startTimestamp","stopTimestamp","addresses","witnessAddresses","payload_schemas","witnessSchema","payloads","archivist","asArchivistInstance","archivistInstance","bwDiviner","asDivinerInstance","resolve","pop","limit","timestamp","more","length","query","schema","BoundWitnessDivinerQuerySchema","boundWitnesses","divine","filter","bw","$timestamp","map","exists","reduce","a","b","Math","min","Number","MAX_SAFE_INTEGER","hashes","payload_hashes","indexOf","batchPayloads","get","push"]}
1
+ {"version":3,"sources":["../../src/MemoryForecastingDiviner.ts"],"sourcesContent":["import { assertEx } from '@xylabs/assert'\nimport { exists } from '@xylabs/exists'\nimport { asArchivistInstance } from '@xyo-network/archivist-model'\nimport type { BoundWitness } from '@xyo-network/boundwitness-model'\nimport type { BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload } from '@xyo-network/diviner-boundwitness-model'\nimport { BoundWitnessDivinerQuerySchema } from '@xyo-network/diviner-boundwitness-model'\nimport type { ForecastingDivinerParams } from '@xyo-network/diviner-forecasting-abstract'\nimport { AbstractForecastingDiviner } from '@xyo-network/diviner-forecasting-abstract'\nimport type {\n arimaForecastingName,\n seasonalArimaForecastingName,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport {\n arimaForecastingMethod,\n seasonalArimaForecastingMethod,\n} from '@xyo-network/diviner-forecasting-method-arima'\nimport type { ForecastingMethod, PayloadValueTransformer } from '@xyo-network/diviner-forecasting-model'\nimport { ForecastingDivinerConfigSchema } from '@xyo-network/diviner-forecasting-model'\nimport type { DivinerInstance } from '@xyo-network/diviner-model'\nimport { asDivinerInstance } from '@xyo-network/diviner-model'\nimport type { ModuleFilter } from '@xyo-network/module-model'\nimport type { Payload, Schema } from '@xyo-network/payload-model'\nimport jsonpath from 'jsonpath'\n\nexport type SupportedForecastingType = typeof arimaForecastingName | typeof seasonalArimaForecastingName\n\nconst getJsonPathTransformer = (pathExpression: string): PayloadValueTransformer => {\n return (x: Payload): number => {\n const ret = jsonpath.value(x, pathExpression)\n if (typeof ret === 'number') return ret\n throw new Error('Parsed invalid payload value')\n }\n}\n\nconst defaultBatchLimit = 1000\nconst defaultMaxTrainingLength = 10_000\n\nexport class MemoryForecastingDiviner<\n TParams extends ForecastingDivinerParams = ForecastingDivinerParams,\n> extends AbstractForecastingDiviner<TParams> {\n static override readonly configSchemas: Schema[] = [...super.configSchemas, ForecastingDivinerConfigSchema]\n static override readonly defaultConfigSchema: Schema = ForecastingDivinerConfigSchema\n\n protected static readonly forecastingMethodDict: Record<SupportedForecastingType, ForecastingMethod> = {\n arimaForecasting: arimaForecastingMethod,\n seasonalArimaForecasting: seasonalArimaForecastingMethod,\n }\n\n get boundWitnessDiviner(): ModuleFilter {\n return assertEx(this.config.boundWitnessDiviner, () => 'No boundWitnessDiviner configured') as ModuleFilter\n }\n\n /**\n * The max number of records to search during the batch query\n */\n protected get batchLimit() {\n return this.config.batchLimit ?? defaultBatchLimit\n }\n\n protected override get forecastingMethod(): ForecastingMethod {\n const forecastingMethodName = assertEx(this.config.forecastingMethod, () => 'Missing forecastingMethod in config') as SupportedForecastingType\n const forecastingMethod = MemoryForecastingDiviner.forecastingMethodDict[forecastingMethodName]\n if (forecastingMethod) return forecastingMethod\n throw new Error(`Unsupported forecasting method: ${forecastingMethodName}`)\n }\n\n protected get maxTrainingLength() {\n return this.config.maxTrainingLength ?? defaultMaxTrainingLength\n }\n\n protected override get transformer(): PayloadValueTransformer {\n const pathExpression = assertEx(this.config.jsonPathExpression, () => 'Missing jsonPathExpression in config')\n return getJsonPathTransformer(pathExpression)\n }\n\n protected override async getPayloadsInWindow(_startTimestamp: number, _stopTimestamp: number): Promise<Payload[]> {\n const addresses = this.config.witnessAddresses\n const payload_schemas = [assertEx(this.config.witnessSchema, () => 'Missing witnessSchema in config')]\n const payloads: Payload[] = []\n const archivist = asArchivistInstance(await this.archivistInstance(), () => 'Unable to resolve archivist')\n const bwDiviner = asDivinerInstance(\n (await this.resolve(this.boundWitnessDiviner)).pop(),\n 'Unable to resolve boundWitnessDiviner',\n ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>\n const limit = this.batchLimit\n const witnessSchema = assertEx(this.config.witnessSchema, () => 'Missing witnessSchema in config')\n // let timestamp = stopTimestamp\n let more = true\n\n // TODO: Window size vs sample size\n // Loop until there are no more BWs to process or we've got enough payloads to satisfy the training window\n while (more || payloads.length < this.maxTrainingLength) {\n const query: BoundWitnessDivinerQueryPayload = {\n addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema,\n }\n const boundWitnesses = (await bwDiviner.divine([query])).filter(\n // TODO; Replace with sequence\n // bw => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp,\n _ => true,\n )\n if (boundWitnesses.length === 0) break\n\n // Update the timestamp value for the next batch\n /* timestamp = boundWitnesses\n .map(bw => bw.$timestamp)\n .filter(exists)\n // eslint-disable-next-line unicorn/no-array-reduce\n .reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER)\n if (timestamp === Number.MAX_SAFE_INTEGER) break\n */\n\n // Set the more flag to false if there are fewer documents returned than the batch size\n more = boundWitnesses.length === limit\n\n // Get the corresponding payload hashes from the BWs\n const hashes = boundWitnesses.map(bw => bw.payload_hashes[bw.payload_schemas.indexOf(witnessSchema)]).filter(exists)\n\n // Get the payloads corresponding to the BW hashes from the archivist\n if (hashes.length > 0) {\n const batchPayloads = (await archivist.get(hashes)).filter(exists)\n payloads.push(...batchPayloads)\n }\n }\n return payloads\n }\n}\n"],"mappings":";;;;AAAA,SAASA,gBAAgB;AACzB,SAASC,cAAc;AACvB,SAASC,2BAA2B;AAGpC,SAASC,sCAAsC;AAE/C,SAASC,kCAAkC;AAK3C,SACEC,w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M,iCAAA;;AACnE,UAAMC,WAAsB,CAAA;AAC5B,UAAMC,YAAYC,oBAAoB,MAAM,KAAKC,kBAAiB,GAAI,MAAM,6BAAA;AAC5E,UAAMC,YAAYC,mBACf,MAAM,KAAKC,QAAQ,KAAKtB,mBAAmB,GAAGuB,IAAG,GAClD,uCAAA;AAEF,UAAMC,QAAQ,KAAKrB;AACnB,UAAMY,gBAAgBd,SAAS,KAAKC,OAAOa,eAAe,MAAM,iCAAA;AAEhE,QAAIU,OAAO;AAIX,WAAOA,QAAQT,SAASU,SAAS,KAAKpB,mBAAmB;AACvD,YAAMqB,QAAyC;QAC7Cf;QAAWY;QAAOV;QAAiBc,QAAQC;MAC7C;AACA,YAAMC,kBAAkB,MAAMV,UAAUW,OAAO;QAACJ;OAAM,GAAGK;;;QAGvDC,CAAAA,MAAK;MAAA;AAEP,UAAIH,eAAeJ,WAAW,EAAG;AAYjCD,aAAOK,eAAeJ,WAAWF;AAGjC,YAAMU,SAASJ,eAAeK,IAAIC,CAAAA,OAAMA,GAAGC,eAAeD,GAAGtB,gBAAgBwB,QAAQvB,aAAAA,CAAAA,CAAe,EAAEiB,OAAOO,MAAAA;AAG7G,UAAIL,OAAOR,SAAS,GAAG;AACrB,cAAMc,iBAAiB,MAAMvB,UAAUwB,IAAIP,MAAAA,GAASF,OAAOO,MAAAA;AAC3DvB,iBAAS0B,KAAI,GAAIF,aAAAA;MACnB;IACF;AACA,WAAOxB;EACT;AACF;","names":["assertEx","exists","asArchivistInstance","BoundWitnessDivinerQuerySchema","AbstractForecastingDiviner","arimaForecastingMethod","seasonalArimaForecastingMethod","ForecastingDivinerConfigSchema","asDivinerInstance","jsonpath","getJsonPathTransformer","pathExpression","x","ret","jsonpath","value","Error","defaultBatchLimit","defaultMaxTrainingLength","MemoryForecastingDiviner","AbstractForecastingDiviner","configSchemas","ForecastingDivinerConfigSchema","defaultConfigSchema","forecastingMethodDict","arimaForecasting","arimaForecastingMethod","seasonalArimaForecasting","seasonalArimaForecastingMethod","boundWitnessDiviner","assertEx","config","batchLimit","forecastingMethod","forecastingMethodName","maxTrainingLength","transformer","jsonPathExpression","getPayloadsInWindow","_startTimestamp","_stopTimestamp","addresses","witnessAddresses","payload_schemas","witnessSchema","payloads","archivist","asArchivistInstance","archivistInstance","bwDiviner","asDivinerInstance","resolve","pop","limit","more","length","query","schema","BoundWitnessDivinerQuerySchema","boundWitnesses","divine","filter","_","hashes","map","bw","payload_hashes","indexOf","exists","batchPayloads","get","push"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xyo-network/diviner-forecasting-memory",
3
- "version": "3.6.0-rc.7",
3
+ "version": "3.6.0-rc.9",
4
4
  "description": "Primary SDK for using XYO Protocol 2.0",
5
5
  "homepage": "https://xyo.network",
6
6
  "bugs": {
@@ -29,17 +29,17 @@
29
29
  "module": "dist/neutral/index.mjs",
30
30
  "types": "dist/neutral/index.d.ts",
31
31
  "dependencies": {
32
- "@xylabs/assert": "^4.4.15",
33
- "@xylabs/exists": "^4.4.15",
34
- "@xyo-network/archivist-model": "^3.6.0-rc.7",
35
- "@xyo-network/boundwitness-model": "^3.6.0-rc.7",
36
- "@xyo-network/diviner-boundwitness-model": "^3.6.0-rc.7",
37
- "@xyo-network/diviner-forecasting-abstract": "^3.6.0-rc.7",
38
- "@xyo-network/diviner-forecasting-method-arima": "^3.6.0-rc.7",
39
- "@xyo-network/diviner-forecasting-model": "^3.6.0-rc.7",
40
- "@xyo-network/diviner-model": "^3.6.0-rc.7",
41
- "@xyo-network/module-model": "^3.6.0-rc.7",
42
- "@xyo-network/payload-model": "^3.6.0-rc.7",
32
+ "@xylabs/assert": "^4.4.18",
33
+ "@xylabs/exists": "^4.4.18",
34
+ "@xyo-network/archivist-model": "^3.6.0-rc.9",
35
+ "@xyo-network/boundwitness-model": "^3.6.0-rc.9",
36
+ "@xyo-network/diviner-boundwitness-model": "^3.6.0-rc.9",
37
+ "@xyo-network/diviner-forecasting-abstract": "^3.6.0-rc.9",
38
+ "@xyo-network/diviner-forecasting-method-arima": "^3.6.0-rc.9",
39
+ "@xyo-network/diviner-forecasting-model": "^3.6.0-rc.9",
40
+ "@xyo-network/diviner-model": "^3.6.0-rc.9",
41
+ "@xyo-network/module-model": "^3.6.0-rc.9",
42
+ "@xyo-network/payload-model": "^3.6.0-rc.9",
43
43
  "jsonpath": "^1.1.1"
44
44
  },
45
45
  "devDependencies": {
@@ -73,7 +73,7 @@ export class MemoryForecastingDiviner<
73
73
  return getJsonPathTransformer(pathExpression)
74
74
  }
75
75
 
76
- protected override async getPayloadsInWindow(startTimestamp: number, stopTimestamp: number): Promise<Payload[]> {
76
+ protected override async getPayloadsInWindow(_startTimestamp: number, _stopTimestamp: number): Promise<Payload[]> {
77
77
  const addresses = this.config.witnessAddresses
78
78
  const payload_schemas = [assertEx(this.config.witnessSchema, () => 'Missing witnessSchema in config')]
79
79
  const payloads: Payload[] = []
@@ -84,7 +84,7 @@ export class MemoryForecastingDiviner<
84
84
  ) as DivinerInstance<BoundWitnessDivinerParams, BoundWitnessDivinerQueryPayload, BoundWitness>
85
85
  const limit = this.batchLimit
86
86
  const witnessSchema = assertEx(this.config.witnessSchema, () => 'Missing witnessSchema in config')
87
- let timestamp = stopTimestamp
87
+ // let timestamp = stopTimestamp
88
88
  let more = true
89
89
 
90
90
  // TODO: Window size vs sample size
@@ -94,17 +94,20 @@ export class MemoryForecastingDiviner<
94
94
  addresses, limit, payload_schemas, schema: BoundWitnessDivinerQuerySchema,
95
95
  }
96
96
  const boundWitnesses = (await bwDiviner.divine([query])).filter(
97
- bw => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp,
97
+ // TODO; Replace with sequence
98
+ // bw => bw.$timestamp && bw.$timestamp >= startTimestamp && bw.$timestamp <= stopTimestamp,
99
+ _ => true,
98
100
  )
99
101
  if (boundWitnesses.length === 0) break
100
102
 
101
103
  // Update the timestamp value for the next batch
102
- timestamp = boundWitnesses
104
+ /* timestamp = boundWitnesses
103
105
  .map(bw => bw.$timestamp)
104
106
  .filter(exists)
105
107
  // eslint-disable-next-line unicorn/no-array-reduce
106
108
  .reduce((a, b) => Math.min(a, b), Number.MAX_SAFE_INTEGER)
107
109
  if (timestamp === Number.MAX_SAFE_INTEGER) break
110
+ */
108
111
 
109
112
  // Set the more flag to false if there are fewer documents returned than the batch size
110
113
  more = boundWitnesses.length === limit