UNPKG

pontus-x_cli

Version:

Command Line Interface for the Pontus-X Data Space Ecosystem.

82 lines 3.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = require("fs"); const nautilus_1 = require("@deltadao/nautilus"); const nautilus_2 = require("@deltadao/nautilus"); const publish = async (folder, connection, provider, dryRun) => { // ALGORITHM USER INPUT DATA const consumerParametersBuilder = new nautilus_1.ConsumerParameterBuilder(); const consumerParameters = []; consumerParameters.push(consumerParametersBuilder .setName("dataset") .setLabel("dataset") .setDescription("Dataset parameters to train the model with, such as: separator, target_column, split, random_state and stratify.") .setDefault(JSON.stringify(JSON.parse((0, fs_1.readFileSync)(`${folder}/dataset-default.json`, "utf8")))) .setRequired(true) .setType("text") .build()); consumerParametersBuilder.reset(); // Reset the builder to create a new parameter consumerParameters.push(consumerParametersBuilder .setName("model") .setLabel("model") .setDescription("Model parameters to train the model with, such as: name, params and metrics.") .setDefault(JSON.stringify(JSON.parse((0, fs_1.readFileSync)(`${folder}/model-default.json`, "utf8")))) .setRequired(true) .setType("text") .build()); // ALGORITHM METADATA const algoMetadata = { language: "python", version: "0.2", container: { entrypoint: "/algorithm/.venv/bin/python /algorithm/src/main.py", image: "clopezgarcia/basic-predictor", tag: "0.1.0", checksum: "sha256:ee1f7f5d3dc6d3323f32f68852aaba8895482a2b4b4e7ff652045b42b7becfbe", }, consumerParameters: consumerParameters, }; const service = new nautilus_2.ServiceBuilder({ serviceType: nautilus_2.ServiceTypes.COMPUTE, fileType: nautilus_2.FileTypes.URL }) .setServiceEndpoint(provider) // the access controller to be in control of this asset .setTimeout(0) // Timeout in seconds (0 means unlimited access after purchase) .addFile({ type: "url", // there are multiple supported data source types, see https://docs.oceanprotocol.com/developers/storage url: "https://raw.githubusercontent.com/AgrospAI/ocean-algo/refs/heads/main/basic-predictor/algorithm/src/main.py", method: "GET", // HTTP request method // headers: { // Authorization: 'Basic XXX' // optional headers field e.g. for basic access control // } }) .setPricing(connection.pricingConfig.fixedRateEUROe(0)) .setDatatokenNameAndSymbol("UdL scikit-learn model trainer", "UDL-SKLEARN") .build(); const asset = new nautilus_1.AssetBuilder() .setType("algorithm") .setName("SciKit-learn algorithm training (working?)") .setAuthor("Universitat de Lleida (UdL)") .setOwner(connection.wallet.address) .setDescription((0, fs_1.readFileSync)(`${folder}/description.md`, "utf8")) .addTags(["ml", "sklearn", "scikit-learn", "tabular-data", "pandas", "udl"]) .setLicense("MIT") .setNftData({ name: "UdL scikit-learn model trainer", symbol: "UDL-SKLEARN", templateIndex: 1, tokenURI: "https://scikit-learn.org/stable/_static/scikit-learn-logo-small.png", transferable: false, }) .setAlgorithm(algoMetadata) .addService(service) .build(); console.log(`Asset metadata: \n ${JSON.stringify(asset, null, 2)}`); if (!dryRun) { console.log(`Publishing asset...`); const result = await connection.nautilus.publish(asset); console.log(`Asset published, ` + `transaction: ${connection.networkConfig.explorerUri}/tx/${result.setMetadataTxReceipt.transactionHash}\n`); } else { console.log("\nDry run completed. Asset not published.\n"); } }; //# sourceMappingURL=index.js.map