最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

autodesk forge - Trouble estimating design automation token usage - Stack Overflow

programmeradmin4浏览0评论

I'm following this article's method to calculate the token usage and then the cost. I run the following calculation on the workitem oncomplete callback and store them in a db.

function getJobMetrics(jobDetails) {
  const { stats } = jobDetails.jobStatus;
  const timeQueued = Date.parse(stats.timeQueued);
  const timeDownloadStarted = Date.parse(stats.timeDownloadStarted);
  const timeUploadEnded = Date.parse(stats.timeUploadEnded);
  const timeInstructionsStarted = Date.parse(stats.timeInstructionsStarted);
  const timeInstructionsEnded = Date.parse(stats.timeInstructionsEnded);
  const queueDelay = timeDownloadStarted - timeQueued;
  const downloadDelay = timeInstructionsStarted - timeDownloadStarted;
  const instructionsRunDuration = timeInstructionsEnded - timeInstructionsStarted;

  const totalDuration = timeInstructionsEnded - timeQueued;
  // 
  // in case of failure, timeUploadEnded is null
  const adskCalculatedTimeTaken = (timeUploadEnded || timeInstructionsEnded) - timeDownloadStarted;
  const adskTokenUsageInCloudCredits = (adskCalculatedTimeTaken / 1000 / 60 / 60) * 6;
  return {
    adskDasQueueDelay: queueDelay, 
    adskDasDownloadDelay: downloadDelay, 
    adskDasInstructionsRunDuration: instructionsRunDuration,
    adskDasTotalDuration: totalDuration, 
    adskDasTotalBytesDownloaded: stats.bytesDownloaded, 
    adskCalculatedTimeTaken,
    adskTokenUsageInCloudCredits, 
  };
}

When I aggregate adskTokenUsageInCloudCredits over time for all the workitems I have in a month, it doesn't match the numbers that I see on the analytics dashboard on APS. My numbers seem an order of magnitude higher. I didn't find any APIs that I can query for individual events that consumed tokens. What am I doing wrong?

I'm following this article's method to calculate the token usage and then the cost. I run the following calculation on the workitem oncomplete callback and store them in a db.

function getJobMetrics(jobDetails) {
  const { stats } = jobDetails.jobStatus;
  const timeQueued = Date.parse(stats.timeQueued);
  const timeDownloadStarted = Date.parse(stats.timeDownloadStarted);
  const timeUploadEnded = Date.parse(stats.timeUploadEnded);
  const timeInstructionsStarted = Date.parse(stats.timeInstructionsStarted);
  const timeInstructionsEnded = Date.parse(stats.timeInstructionsEnded);
  const queueDelay = timeDownloadStarted - timeQueued;
  const downloadDelay = timeInstructionsStarted - timeDownloadStarted;
  const instructionsRunDuration = timeInstructionsEnded - timeInstructionsStarted;

  const totalDuration = timeInstructionsEnded - timeQueued;
  // https://aps.autodesk/blog/estimate-design-automation-costs
  // in case of failure, timeUploadEnded is null
  const adskCalculatedTimeTaken = (timeUploadEnded || timeInstructionsEnded) - timeDownloadStarted;
  const adskTokenUsageInCloudCredits = (adskCalculatedTimeTaken / 1000 / 60 / 60) * 6;
  return {
    adskDasQueueDelay: queueDelay, 
    adskDasDownloadDelay: downloadDelay, 
    adskDasInstructionsRunDuration: instructionsRunDuration,
    adskDasTotalDuration: totalDuration, 
    adskDasTotalBytesDownloaded: stats.bytesDownloaded, 
    adskCalculatedTimeTaken,
    adskTokenUsageInCloudCredits, 
  };
}

When I aggregate adskTokenUsageInCloudCredits over time for all the workitems I have in a month, it doesn't match the numbers that I see on the analytics dashboard on APS. My numbers seem an order of magnitude higher. I didn't find any APIs that I can query for individual events that consumed tokens. What am I doing wrong?

Share Improve this question asked 2 days ago solmanssolmans 5776 silver badges17 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

DA API charges 2 cloud credits per processing hour/

const adskTokenUsageInCloudCredits = (adskCalculatedTimeTaken / 1000 / 60 / 60) * 2

Refer https://aps.autodesk/pricing

发布评论

评论列表(0)

  1. 暂无评论