@pd4castr/cli 1.6.0 → 1.7.0
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.
- package/dist/index.js +77 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -94,6 +94,62 @@ var inputAggregationSchema = z.object({
|
|
|
94
94
|
description: z.string().optional().default(""),
|
|
95
95
|
colours: z.array(z.string()).optional().default([])
|
|
96
96
|
});
|
|
97
|
+
var performanceMetricsOptionValueEntrySchema = z.object({
|
|
98
|
+
label: z.string(),
|
|
99
|
+
key: z.string()
|
|
100
|
+
});
|
|
101
|
+
var performanceMetricsSelectOptionSchema = z.object({
|
|
102
|
+
label: z.string(),
|
|
103
|
+
key: z.string(),
|
|
104
|
+
type: z.literal("select"),
|
|
105
|
+
values: z.array(performanceMetricsOptionValueEntrySchema).min(1),
|
|
106
|
+
defaultValue: z.string().optional()
|
|
107
|
+
});
|
|
108
|
+
var performanceMetricsNumberOptionSchema = z.object({
|
|
109
|
+
label: z.string(),
|
|
110
|
+
key: z.string(),
|
|
111
|
+
type: z.literal("number"),
|
|
112
|
+
defaultValue: z.number().optional()
|
|
113
|
+
});
|
|
114
|
+
var performanceMetricsDateOptionSchema = z.object({
|
|
115
|
+
label: z.string(),
|
|
116
|
+
key: z.string(),
|
|
117
|
+
type: z.literal("date"),
|
|
118
|
+
defaultValue: z.string().optional(),
|
|
119
|
+
maxDate: z.string().optional()
|
|
120
|
+
});
|
|
121
|
+
var performanceMetricsBooleanOptionSchema = z.object({
|
|
122
|
+
label: z.string(),
|
|
123
|
+
key: z.string(),
|
|
124
|
+
type: z.literal("boolean"),
|
|
125
|
+
defaultValue: z.boolean().optional()
|
|
126
|
+
});
|
|
127
|
+
var performanceMetricsRangeInputOptionSchema = z.discriminatedUnion("type", [
|
|
128
|
+
performanceMetricsSelectOptionSchema,
|
|
129
|
+
performanceMetricsNumberOptionSchema,
|
|
130
|
+
performanceMetricsDateOptionSchema
|
|
131
|
+
]);
|
|
132
|
+
var performanceMetricsRangeOptionSchema = z.object({
|
|
133
|
+
label: z.string(),
|
|
134
|
+
key: z.string(),
|
|
135
|
+
type: z.literal("range"),
|
|
136
|
+
inputs: z.tuple([
|
|
137
|
+
performanceMetricsRangeInputOptionSchema,
|
|
138
|
+
performanceMetricsRangeInputOptionSchema
|
|
139
|
+
])
|
|
140
|
+
});
|
|
141
|
+
var performanceMetricsOptionSchema = z.discriminatedUnion("type", [
|
|
142
|
+
performanceMetricsSelectOptionSchema,
|
|
143
|
+
performanceMetricsNumberOptionSchema,
|
|
144
|
+
performanceMetricsDateOptionSchema,
|
|
145
|
+
performanceMetricsBooleanOptionSchema,
|
|
146
|
+
performanceMetricsRangeOptionSchema
|
|
147
|
+
]);
|
|
148
|
+
var performanceMetricsSchema = z.object({
|
|
149
|
+
options: z.array(performanceMetricsOptionSchema).optional().default([]),
|
|
150
|
+
comparisonModels: z.record(z.string(), z.string()).optional().default({}),
|
|
151
|
+
query: z.string().min(1)
|
|
152
|
+
});
|
|
97
153
|
var CONFIG_WARNING_KEY = "// WARNING: DO NOT MODIFY THESE SYSTEM MANAGED VALUES";
|
|
98
154
|
var projectConfigSchema = z.object({
|
|
99
155
|
name: z.string(),
|
|
@@ -114,6 +170,7 @@ var projectConfigSchema = z.object({
|
|
|
114
170
|
inputAggregations: z.array(inputAggregationSchema).optional().default([]),
|
|
115
171
|
outputs: z.array(modelOutputSchema),
|
|
116
172
|
sensitivities: z.array(sensitivitySchema).optional().default([]),
|
|
173
|
+
performanceMetrics: performanceMetricsSchema.nullable().optional().default(null),
|
|
117
174
|
[CONFIG_WARNING_KEY]: z.string().optional().default(""),
|
|
118
175
|
$$id: z.string().nullable().optional().default(null),
|
|
119
176
|
$$modelGroupID: z.string().nullable().optional().default(null),
|
|
@@ -811,6 +868,7 @@ async function getModelConfigFromProjectConfig(ctx) {
|
|
|
811
868
|
const sensitivities = await getSensitivitiesWithInlinedSQL(ctx);
|
|
812
869
|
const inputAggregations = await getInputAggregationsWithInlinedSQL(ctx);
|
|
813
870
|
const runDatetimeQuery = await getrunDatetimeQuerySQL(ctx);
|
|
871
|
+
const performanceMetrics = await getPerformanceMetricsWithInlinedSQL(ctx);
|
|
814
872
|
const { $$id, $$modelGroupID, $$revision, $$dockerImage, ...config } = ctx.config;
|
|
815
873
|
return {
|
|
816
874
|
...config,
|
|
@@ -821,7 +879,8 @@ async function getModelConfigFromProjectConfig(ctx) {
|
|
|
821
879
|
inputs,
|
|
822
880
|
sensitivities,
|
|
823
881
|
inputAggregations,
|
|
824
|
-
runDatetimeQuery
|
|
882
|
+
runDatetimeQuery,
|
|
883
|
+
performanceMetrics
|
|
825
884
|
};
|
|
826
885
|
}
|
|
827
886
|
__name(getModelConfigFromProjectConfig, "getModelConfigFromProjectConfig");
|
|
@@ -905,6 +964,22 @@ async function getrunDatetimeQuerySQL(ctx) {
|
|
|
905
964
|
}
|
|
906
965
|
}
|
|
907
966
|
__name(getrunDatetimeQuerySQL, "getrunDatetimeQuerySQL");
|
|
967
|
+
async function getPerformanceMetricsWithInlinedSQL(ctx) {
|
|
968
|
+
if (ctx.config.performanceMetrics === null) {
|
|
969
|
+
return null;
|
|
970
|
+
}
|
|
971
|
+
try {
|
|
972
|
+
const queryPath = path9.resolve(ctx.projectRoot, ctx.config.performanceMetrics.query);
|
|
973
|
+
const sql = await fs8.readFile(queryPath, "utf8");
|
|
974
|
+
return {
|
|
975
|
+
...ctx.config.performanceMetrics,
|
|
976
|
+
query: sql
|
|
977
|
+
};
|
|
978
|
+
} catch {
|
|
979
|
+
throw new Error(`Performance metrics query file not found (${ctx.config.performanceMetrics.query})`);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
__name(getPerformanceMetricsWithInlinedSQL, "getPerformanceMetricsWithInlinedSQL");
|
|
908
983
|
|
|
909
984
|
// src/utils/log-empty-line.ts
|
|
910
985
|
function logEmptyLine() {
|
|
@@ -1692,7 +1767,7 @@ import { Command } from "commander";
|
|
|
1692
1767
|
// package.json
|
|
1693
1768
|
var package_default = {
|
|
1694
1769
|
name: "@pd4castr/cli",
|
|
1695
|
-
version: "1.
|
|
1770
|
+
version: "1.7.0",
|
|
1696
1771
|
description: "CLI tool for creating, testing, and publishing pd4castr models",
|
|
1697
1772
|
license: "UNLICENSED",
|
|
1698
1773
|
main: "dist/index.js",
|