Team Ai
Datasetpublic

Brunobkr/llama.cpp_AlgMor24_github

ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.

sourceHugging Faceupdated 2mo agoView on Hugging Face
0likes3.1kdownloads
testTracing.js345 linesDownload Raw Back to worker
1"use strict";2var __create = Object.create;3var __defProp = Object.defineProperty;4var __getOwnPropDesc = Object.getOwnPropertyDescriptor;5var __getOwnPropNames = Object.getOwnPropertyNames;6var __getProtoOf = Object.getPrototypeOf;7var __hasOwnProp = Object.prototype.hasOwnProperty;8var __export = (target, all) => {9  for (var name in all)10    __defProp(target, name, { get: all[name], enumerable: true });11};12var __copyProps = (to, from, except, desc) => {13  if (from && typeof from === "object" || typeof from === "function") {14    for (let key of __getOwnPropNames(from))15      if (!__hasOwnProp.call(to, key) && key !== except)16        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });17  }18  return to;19};20var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(21  // If the importer is in node compatibility mode or this is not an ESM22  // file that has been converted to a CommonJS file using a Babel-23  // compatible transform (i.e. "__esModule" has not been set), then set24  // "default" to the CommonJS "module.exports" for node compatibility.25  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,26  mod27));28var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);29var testTracing_exports = {};30__export(testTracing_exports, {31  TestTracing: () => TestTracing,32  testTraceEntryName: () => testTraceEntryName33});34module.exports = __toCommonJS(testTracing_exports);35var import_fs = __toESM(require("fs"));36var import_path = __toESM(require("path"));37var import_utils = require("playwright-core/lib/utils");38var import_zipBundle = require("playwright-core/lib/zipBundle");39var import_util = require("../util");40const testTraceEntryName = "test.trace";41const version = 8;42let traceOrdinal = 0;43class TestTracing {44  constructor(testInfo, artifactsDir) {45    this._traceEvents = [];46    this._temporaryTraceFiles = [];47    this._didFinishTestFunctionAndAfterEachHooks = false;48    this._testInfo = testInfo;49    this._artifactsDir = artifactsDir;50    this._tracesDir = import_path.default.join(this._artifactsDir, "traces");51    this._contextCreatedEvent = {52      version,53      type: "context-options",54      origin: "testRunner",55      browserName: "",56      options: {},57      platform: process.platform,58      wallTime: Date.now(),59      monotonicTime: (0, import_utils.monotonicTime)(),60      sdkLanguage: "javascript"61    };62    this._appendTraceEvent(this._contextCreatedEvent);63  }64  _shouldCaptureTrace() {65    if (this._options?.mode === "on")66      return true;67    if (this._options?.mode === "retain-on-failure")68      return true;69    if (this._options?.mode === "on-first-retry" && this._testInfo.retry === 1)70      return true;71    if (this._options?.mode === "on-all-retries" && this._testInfo.retry > 0)72      return true;73    if (this._options?.mode === "retain-on-first-failure" && this._testInfo.retry === 0)74      return true;75    return false;76  }77  async startIfNeeded(value) {78    const defaultTraceOptions = { screenshots: true, snapshots: true, sources: true, attachments: true, _live: false, mode: "off" };79    if (!value) {80      this._options = defaultTraceOptions;81    } else if (typeof value === "string") {82      this._options = { ...defaultTraceOptions, mode: value === "retry-with-trace" ? "on-first-retry" : value };83    } else {84      const mode = value.mode || "off";85      this._options = { ...defaultTraceOptions, ...value, mode: mode === "retry-with-trace" ? "on-first-retry" : mode };86    }87    if (!this._shouldCaptureTrace()) {88      this._options = void 0;89      return;90    }91    if (!this._liveTraceFile && this._options._live) {92      this._liveTraceFile = { file: import_path.default.join(this._tracesDir, `${this._testInfo.testId}-test.trace`), fs: new import_utils.SerializedFS() };93      this._liveTraceFile.fs.mkdir(import_path.default.dirname(this._liveTraceFile.file));94      const data = this._traceEvents.map((e) => JSON.stringify(e)).join("\n") + "\n";95      this._liveTraceFile.fs.writeFile(this._liveTraceFile.file, data);96    }97  }98  didFinishTestFunctionAndAfterEachHooks() {99    this._didFinishTestFunctionAndAfterEachHooks = true;100  }101  artifactsDir() {102    return this._artifactsDir;103  }104  tracesDir() {105    return this._tracesDir;106  }107  traceTitle() {108    return [import_path.default.relative(this._testInfo.project.testDir, this._testInfo.file) + ":" + this._testInfo.line, ...this._testInfo.titlePath.slice(1)].join(" \u203A ");109  }110  generateNextTraceRecordingName() {111    const ordinalSuffix = traceOrdinal ? `-recording${traceOrdinal}` : "";112    ++traceOrdinal;113    const retrySuffix = this._testInfo.retry ? `-retry${this._testInfo.retry}` : "";114    return `${this._testInfo.testId}${retrySuffix}${ordinalSuffix}`;115  }116  _generateNextTraceRecordingPath() {117    const file = import_path.default.join(this._artifactsDir, (0, import_utils.createGuid)() + ".zip");118    this._temporaryTraceFiles.push(file);119    return file;120  }121  traceOptions() {122    return this._options;123  }124  maybeGenerateNextTraceRecordingPath() {125    if (this._didFinishTestFunctionAndAfterEachHooks && this._shouldAbandonTrace())126      return;127    return this._generateNextTraceRecordingPath();128  }129  _shouldAbandonTrace() {130    if (!this._options)131      return true;132    const testFailed = this._testInfo.status !== this._testInfo.expectedStatus;133    return !testFailed && (this._options.mode === "retain-on-failure" || this._options.mode === "retain-on-first-failure");134  }135  async stopIfNeeded() {136    if (!this._options)137      return;138    const error = await this._liveTraceFile?.fs.syncAndGetError();139    if (error)140      throw error;141    if (this._shouldAbandonTrace()) {142      for (const file of this._temporaryTraceFiles)143        await import_fs.default.promises.unlink(file).catch(() => {144        });145      return;146    }147    const zipFile = new import_zipBundle.yazl.ZipFile();148    if (!this._options?.attachments) {149      for (const event of this._traceEvents) {150        if (event.type === "after")151          delete event.attachments;152      }153    }154    if (this._options?.sources) {155      const sourceFiles = /* @__PURE__ */ new Set();156      for (const event of this._traceEvents) {157        if (event.type === "before") {158          for (const frame of event.stack || [])159            sourceFiles.add(frame.file);160        }161      }162      for (const sourceFile of sourceFiles) {163        await import_fs.default.promises.readFile(sourceFile, "utf8").then((source) => {164          zipFile.addBuffer(Buffer.from(source), "resources/src@" + (0, import_utils.calculateSha1)(sourceFile) + ".txt");165        }).catch(() => {166        });167      }168    }169    const sha1s = /* @__PURE__ */ new Set();170    for (const event of this._traceEvents.filter((e) => e.type === "after")) {171      for (const attachment of event.attachments || []) {172        let contentPromise;173        if (attachment.path)174          contentPromise = import_fs.default.promises.readFile(attachment.path).catch(() => void 0);175        else if (attachment.base64)176          contentPromise = Promise.resolve(Buffer.from(attachment.base64, "base64"));177        const content = await contentPromise;178        if (content === void 0)179          continue;180        const sha1 = (0, import_utils.calculateSha1)(content);181        attachment.sha1 = sha1;182        delete attachment.path;183        delete attachment.base64;184        if (sha1s.has(sha1))185          continue;186        sha1s.add(sha1);187        zipFile.addBuffer(content, "resources/" + sha1);188      }189    }190    const traceContent = Buffer.from(this._traceEvents.map((e) => JSON.stringify(e)).join("\n"));191    zipFile.addBuffer(traceContent, testTraceEntryName);192    await new Promise((f) => {193      zipFile.end(void 0, () => {194        zipFile.outputStream.pipe(import_fs.default.createWriteStream(this._generateNextTraceRecordingPath())).on("close", f);195      });196    });197    const tracePath = this._testInfo.outputPath("trace.zip");198    await mergeTraceFiles(tracePath, this._temporaryTraceFiles);199    this._testInfo.attachments.push({ name: "trace", path: tracePath, contentType: "application/zip" });200  }201  appendForError(error) {202    const rawStack = error.stack?.split("\n") || [];203    const stack = rawStack ? (0, import_util.filteredStackTrace)(rawStack) : [];204    this._appendTraceEvent({205      type: "error",206      message: this._formatError(error),207      stack208    });209  }210  _formatError(error) {211    const parts = [error.message || String(error.value)];212    if (error.cause)213      parts.push("[cause]: " + this._formatError(error.cause));214    return parts.join("\n");215  }216  appendStdioToTrace(type, chunk) {217    this._appendTraceEvent({218      type,219      timestamp: (0, import_utils.monotonicTime)(),220      text: typeof chunk === "string" ? chunk : void 0,221      base64: typeof chunk === "string" ? void 0 : chunk.toString("base64")222    });223  }224  appendBeforeActionForStep(options) {225    this._appendTraceEvent({226      type: "before",227      callId: options.stepId,228      stepId: options.stepId,229      parentId: options.parentId,230      startTime: (0, import_utils.monotonicTime)(),231      class: "Test",232      method: options.category,233      title: options.title,234      params: Object.fromEntries(Object.entries(options.params || {}).map(([name, value]) => [name, generatePreview(value)])),235      stack: options.stack,236      group: options.group237    });238  }239  appendAfterActionForStep(callId, error, attachments = [], annotations) {240    this._appendTraceEvent({241      type: "after",242      callId,243      endTime: (0, import_utils.monotonicTime)(),244      attachments: serializeAttachments(attachments),245      annotations,246      error247    });248  }249  _appendTraceEvent(event) {250    this._traceEvents.push(event);251    if (this._liveTraceFile)252      this._liveTraceFile.fs.appendFile(this._liveTraceFile.file, JSON.stringify(event) + "\n", true);253  }254}255function serializeAttachments(attachments) {256  if (attachments.length === 0)257    return void 0;258  return attachments.filter((a) => a.name !== "trace").map((a) => {259    return {260      name: a.name,261      contentType: a.contentType,262      path: a.path,263      base64: a.body?.toString("base64")264    };265  });266}267function generatePreview(value, visited = /* @__PURE__ */ new Set()) {268  if (visited.has(value))269    return "";270  visited.add(value);271  if (typeof value === "string")272    return value;273  if (typeof value === "number")274    return value.toString();275  if (typeof value === "boolean")276    return value.toString();277  if (value === null)278    return "null";279  if (value === void 0)280    return "undefined";281  if (Array.isArray(value))282    return "[" + value.map((v) => generatePreview(v, visited)).join(", ") + "]";283  if (typeof value === "object")284    return "Object";285  return String(value);286}287async function mergeTraceFiles(fileName, temporaryTraceFiles) {288  temporaryTraceFiles = temporaryTraceFiles.filter((file) => import_fs.default.existsSync(file));289  if (temporaryTraceFiles.length === 1) {290    await import_fs.default.promises.rename(temporaryTraceFiles[0], fileName);291    return;292  }293  const mergePromise = new import_utils.ManualPromise();294  const zipFile = new import_zipBundle.yazl.ZipFile();295  const entryNames = /* @__PURE__ */ new Set();296  zipFile.on("error", (error) => mergePromise.reject(error));297  for (let i = temporaryTraceFiles.length - 1; i >= 0; --i) {298    const tempFile = temporaryTraceFiles[i];299    const promise = new import_utils.ManualPromise();300    import_zipBundle.yauzl.open(tempFile, (err, inZipFile) => {301      if (err) {302        promise.reject(err);303        return;304      }305      let pendingEntries = inZipFile.entryCount;306      inZipFile.on("entry", (entry) => {307        let entryName = entry.fileName;308        if (entry.fileName === testTraceEntryName) {309        } else if (entry.fileName.match(/trace\.[a-z]*$/)) {310          entryName = i + "-" + entry.fileName;311        }312        if (entryNames.has(entryName)) {313          if (--pendingEntries === 0)314            promise.resolve();315          return;316        }317        entryNames.add(entryName);318        inZipFile.openReadStream(entry, (err2, readStream) => {319          if (err2) {320            promise.reject(err2);321            return;322          }323          zipFile.addReadStream(readStream, entryName);324          if (--pendingEntries === 0)325            promise.resolve();326        });327      });328    });329    await promise;330  }331  zipFile.end(void 0, () => {332    zipFile.outputStream.pipe(import_fs.default.createWriteStream(fileName)).on("close", () => {333      void Promise.all(temporaryTraceFiles.map((tempFile) => import_fs.default.promises.unlink(tempFile))).then(() => {334        mergePromise.resolve();335      }).catch((error) => mergePromise.reject(error));336    }).on("error", (error) => mergePromise.reject(error));337  });338  await mergePromise;339}340// Annotate the CommonJS export names for ESM import in node:3410 && (module.exports = {342  TestTracing,343  testTraceEntryName344});345 
Brunobkr/llama.cpp_AlgMor24_github · Team Ai