mirror of
https://github.com/velocitatem/PHANTOM.git
synced 2026-05-31 08:33:36 +00:00
Airflow addition (#28)
* introducing airflow to run pipeline * chore: updating dag with upload to registry * introducing complete provider (non refactored and noisy) * chore: removing old shit * generic pricing baselines * feature: super simple model registry (to be updated maybe third party OS software) * chore: refactoring the providers docker config and requirements * chore: refactored and broke down components (braking * exporting all * local pipeline excution working * fix: fixing import structures from nonrelativistic * chore: enables cross comm pickling with fully e2e pipeline compilation * docs: what the pipeline is like now * pipelines local running and pipeline high level definition * cleaning old pipeline and vectorization * leaked but fixing, not so important * test: started with pipeline step testing * chore: cleaning up provider of prices * test: extra tests wit hsemantic meaning checks * migrating pricers * feature: introducing pricing predictors (pricers) * chore: e2e is done with new pipeline * extra session feature extraction * feature: experiemntal sessin pricer and metrics(vibe) * chore: redefined and connected pricers (#29)
This commit is contained in:
committed by
GitHub
parent
2a0e44ab24
commit
ad9423bf59
@@ -20,10 +20,40 @@ export async function GET(req: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
// stub: call external pricing provider (random for now)
|
||||
const basePrice = 100 + Math.random() * 900; // 100-1000 range
|
||||
const price = Math.round(basePrice * 100) / 100;
|
||||
const timestamp = new Date().toISOString();
|
||||
let price: number;
|
||||
let basePrice: number | undefined;
|
||||
let markup: number | undefined;
|
||||
let elasticity: number | undefined;
|
||||
|
||||
// call real pricing provider
|
||||
const providerUrl = process.env.PRICING_PROVIDER_URL || 'http://localhost:5001';
|
||||
try {
|
||||
const queryParams = new URLSearchParams();
|
||||
if (sessionId) queryParams.append('sessionId', sessionId);
|
||||
if (experimentId) queryParams.append('experimentId', experimentId);
|
||||
|
||||
const providerResponse = await fetch(
|
||||
`${providerUrl}/api/${storeMode}/price/${productId}?${queryParams.toString()}`,
|
||||
{ headers: { 'Accept': 'application/json' }, cache: 'no-store' }
|
||||
);
|
||||
|
||||
if (!providerResponse.ok) {
|
||||
throw new Error(`Provider returned ${providerResponse.status}`);
|
||||
}
|
||||
|
||||
const providerData = await providerResponse.json();
|
||||
price = providerData.price;
|
||||
basePrice = providerData.base_price;
|
||||
markup = providerData.markup;
|
||||
elasticity = providerData.elasticity;
|
||||
|
||||
} catch (err) {
|
||||
console.error('[pricing-provider-error]', err);
|
||||
// fallback to random pricing if provider unavailable
|
||||
const randomBase = 100 + Math.random() * 900;
|
||||
price = Math.round(randomBase * 100) / 100;
|
||||
}
|
||||
|
||||
// log price to kafka for elasticity computation
|
||||
if (sessionId) {
|
||||
@@ -43,19 +73,13 @@ export async function GET(req: NextRequest) {
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('[price-log-error]', err);
|
||||
// don't fail the pricing request if logging fails
|
||||
}
|
||||
}
|
||||
|
||||
// log in dev
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.log('[pricing-api]', {
|
||||
productId,
|
||||
sessionId,
|
||||
experimentId,
|
||||
storeMode,
|
||||
price,
|
||||
timestamp,
|
||||
productId, sessionId, experimentId, storeMode,
|
||||
price, basePrice, markup, elasticity, timestamp,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user