UNPKG

pontus-x_cli

Version:

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

62 lines 2.85 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) => { const assetBuilder = new nautilus_1.AssetBuilder(); assetBuilder.setType('algorithm') .setName('Exploratory Data Analysis') .setAuthor('Universitat de Lleida (UdL)') .setOwner(connection.wallet.address) .setDescription((0, fs_1.readFileSync)(`${folder}/description.md`, 'utf8')) .addTags(['eda', 'exploratory data analysis', 'profiling', 'tabular-data', 'pandas', 'agrospai', 'udl']) .setLicense('MIT') .setNftData({ name: 'UdL EDA Algo', symbol: 'UDL-EDA', templateIndex: 1, tokenURI: 'https://docs.profiling.ydata.ai/latest/_static/img/multivariate_profiling.png', transferable: false }); const algoMetadata = { language: 'python', version: '0.2', container: { entrypoint: 'python $ALGO', image: 'rogargon/pandas-profiling', tag: '4.9.0', checksum: 'sha256:105d404c9b00438c08c2199d5356fcd17d7349cff514c923d066ced56d9baa93' } }; assetBuilder.setAlgorithm(algoMetadata); const serviceBuilder = new nautilus_2.ServiceBuilder({ serviceType: nautilus_2.ServiceTypes.ACCESS, fileType: nautilus_2.FileTypes.URL }); const urlFile = { type: 'url', // there are multiple supported data source types, see https://docs.oceanprotocol.com/developers/storage url: 'https://raw.githubusercontent.com/rogargon/ocean-algo/eda/eda.py', method: 'GET' // HTTP request method // headers: { // Authorization: 'Basic XXX' // optional headers field e.g. for basic access control // } }; const service = serviceBuilder .setServiceEndpoint(provider) // the access controller to be in control of this asset .setTimeout(0) // Timeout in seconds (0 means unlimited access after purchase) .addFile(urlFile) .setPricing(connection.pricingConfig.fixedRateEUROe(0)) .setDatatokenNameAndSymbol('UdL EDA Algo', 'UDL-EDA') .build(); assetBuilder.addService(service); const asset = assetBuilder.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