1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

added cli docs

This commit is contained in:
Bogdan Fazakas 2023-09-28 14:02:05 +03:00
parent e8dad41707
commit b13b01cb85
9 changed files with 197 additions and 0 deletions

View File

@ -0,0 +1,15 @@
---
description: >-
CLI tool to interact with the oceanprotocol's JavaScript library to privately & securely publish, consume and run compute on data.
---
# Ocean CLI
The Ocean CLI tool offers a range of functionalities, including the ability to:
- **Publish** data services: downloadable files or compute-to-data.
- **Edit** existing assets.
- **Consume** data services, ordering datatokens and downloading data.
- **Compute to data** on public available datasets using a published algorithm.
Ocean CLI is using ocean.js Javascripti library witch is part of the [Ocean Protocol](https://oceanprotocol.com) toolset.

View File

@ -0,0 +1,9 @@
# Consuming an asset
The process of consuming an asset is remarkably straightforward. To achieve this, you only need to execute a single command: <code>npm run cli download 'assetDID' 'download-location-path'</code>
In this command, replace 'assetDID' with the specific DID of the asset you want to consume, and 'download-location-path' with the desired path where you wish to store the downloaded asset content
Once executed, this command seamlessly orchestrates both the ordering of datatoken and the subsequent download operation. The asset's content will be automatically retrieved and saved at the specified location, simplifying the consumption process for users.
<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzQlpIJEeu8x5yl0OLuXn%2Fuploads%2Fqiex0R1FVw2XSzqmSdu6%2FScreenshot%202023-09-28%20at%2001.25.23.png?alt=media&token=70f5e7b7-6698-4817-824c-28ea7483d39c alt=""><figcaption>dowload method example</figcaption></figure>

View File

@ -0,0 +1,11 @@
# Downloading compute results
To retrieve the compute results, we'll employ two distinct methods. Initially, we'll use the getJobStatus method, where we'll wait for or periodically check the status until it indicates that the job is finished. Subsequently, we'll utilize the method to obtain the actual results.
For the first method, you'll need both the dataset DID and the compute job DID. You can execute the following command: <code>npm run cli getJobStatus 'DATASET_DID' 'JOB_ID'</code>. This command will enable you to monitor the status of the job and ensure it has completed successfully.
<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzQlpIJEeu8x5yl0OLuXn%2Fuploads%2FGURaTt0siyBHMDLwD1s5%2FScreenshot%202023-09-28%20at%2001.59.14.png?alt=media&token=528bd4e0-4a48-43f1-924d-c32976a7663b" alt=""><figcaption>getJobStatus</figcaption></figure>
For the second method, the dataset DID is no longer required. Instead, you'll need to specify the job ID, the index of the result you wish to download from the available results for that job, and the destination folder where you want to save the downloaded content. The corresponding command is as follows: <code> npm run cli downloadJobResults 'JOB_ID' 'RESULT_INDEX' 'DESTINATION_FOLDER'</code>
<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzQlpIJEeu8x5yl0OLuXn%2Fuploads%2FjvvCAOQVQvAv2ygNtPby%2FScreenshot%202023-09-28%20at%2002.01.42.png?alt=media&token=da8868d7-6fdb-4dce-ac9a-6b395a0960e5 alt=""><figcaption>downloadJobResults</figcaption></figure>

View File

@ -0,0 +1,5 @@
# Getting asset DDO
Obtaining the DDO of an asset is a straightforward process. You can accomplish this task by executing the following command: npm run cli getDDO 'assetDID'
<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzQlpIJEeu8x5yl0OLuXn%2Fuploads%2Fh3AQakJYiL7sDUEvfxhA%2FScreenshot%202023-09-28%20at%2001.06.55.png?alt=media&token=7c6c527a-b0cc-4517-8ec3-48cf27782261" alt=""><figcaption>getDDO method example</figcaption></figure>

View File

@ -0,0 +1,27 @@
# Installation
**Clone the Repository**: Begin by cloning the repository. You can achieve this by executing the following command in your terminal:
<pre><code>```bash
#!/bin/bash
$ git clone https://github.com/oceanprotocol/ocean.js-cli.git
```
</code></pre>
Cloning the repository will create a local copy on your machine, allowing you to access and work with its contents.
**Install NPM Dependencies**: After successfully cloning the repository, you should install the necessary npm dependencies to ensure that the project functions correctly. This can be done with the following command:
<pre><code>```bash
#!/bin/bash
npm install
```
</code></pre>
Build the TypeScript code
<pre><code>```bash
#!/bin/bash
npm run build
```
</code></pre>

View File

@ -0,0 +1,81 @@
# Publish a dataset
Once the RPC environment variable has been configured, we can proceed to publish a new dataset on the connected network. The flexibility of our setup allows us to easily switch to a different network by simply substituting the RPC endpoint with one corresponding to another network.
To initiate this process, we'll begin by updating the helper DDO example named "SimpleDownloadDataset.json." This example can be found in the "./metadata" folder, which is located at the root directory of the cloned Ocean CLI project.
<pre><code>```json
{
"@context": [
"https://w3id.org/did/v1"
],
"id": "",
"nftAddress": "",
"version": "4.1.0",
"chainId": 80001,
"metadata": {
"created": "2021-12-20T14:35:20Z",
"updated": "2021-12-20T14:35:20Z",
"type": "dataset",
"name": "ocean-cli demo asset",
"description": "asset published using ocean cli tool",
"tags": [
"test"
],
"author": "oceanprotocol",
"license": "https://market.oceanprotocol.com/terms",
"additionalInformation": {
"termsAndConditions": true
}
},
"services": [
{
"id": "ccb398c50d6abd5b456e8d7242bd856a1767a890b537c2f8c10ba8b8a10e6025",
"type": "access",
"files": {
"datatokenAddress": "0x0",
"nftAddress": "0x0",
"files": [
{
"type": "url",
"url": "https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-abstract10.xml.gz-rss.xml",
"method": "GET"
}
]
},
"datatokenAddress": "",
"serviceEndpoint": "https://v4.provider.oceanprotocol.com",
"timeout": 86400
}
],
"event": {
},
"nft": {
"address": "",
"name": "Ocean Data NFT",
"symbol": "OCEAN-NFT",
"state": 5,
"tokenURI": "",
"owner": "",
"created": ""
},
"purgatory": {
"state": false
},
"datatokens": [
],
"stats": {
"allocated": 0,
"orders": 0,
"price": {
"value": "2"
}
}
}
```
</code></pre>
Note: The provided example creates a consumable asset with a predetermined price of 2 OCEAN tokens. If you wish to modify this and create an asset that is freely accessible, you can do so by replacing the value of "stats.price.value" with 0 in the JSON example mentioned above.
Next step is to run the npm run cli publish metadata/simpleDownloadDataset.json command
<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzQlpIJEeu8x5yl0OLuXn%2Fuploads%2F0WBqBdns3Nqip0W91uld%2FScreenshot%202023-09-28%20at%2000.58.48.png?alt=media&token=29806606-4029-4979-85a5-a3d02bb0a79d" alt=""><figcaption>running publish command</figcaption></figure>

View File

@ -0,0 +1,29 @@
# Setting environment variables
To successfully configure the CLI tool, two essential steps must be undertaken: the setting of the account's private key and the definition of the desired RPC endpoint. These actions are pivotal in enabling the CLI tool to function effectively.
**Private Key Configuration**: The CLI tool necessitates the configuration of the account's private key. This private key serves as the means by which the CLI tool establishes a connection to the associated wallet. It plays a crucial role in authenticating and authorizing operations performed by the tool.
<pre><code>```bash
#!/bin/bash
export MNEMONIC="XXXX"
```
</code></pre>
**RPC Endpoint Specification**: Additionally, it is imperative to specify the RPC endpoint that corresponds to the desired network for executing operations. The CLI tool relies on this user-provided RPC endpoint to connect to the network required for its functions. This connection to the network is vital as it enables the CLI tool to interact with the blockchain and execute operations seamlessly.
<pre><code>```bash
#!/bin/bash
export RPC='XXXX'
```
</code></pre>
Furthermore, there are additional environment variables that can be configured to enhance the flexibility and customization of the environment. These variables include options such as the metadataCache URL and Provider URL, which can be specified if you prefer to utilize a custom deployment of Aquarius or Provider in contrast of the default settings. Moreover, you have the option to provide a custom address file path if you wish to use customized smart contracts or deployments for your specific use case. Remeber setting the next envariament variables is optional.
<pre><code>```bash
#!/bin/bash
export AQUARIUS_URL='XXXX'
export PROVIDER_URL='XXXX'
export ADDRESS_FILE='../path/to/your/address-file'
```
</code></pre>

View File

@ -0,0 +1,9 @@
# Starting a compute job
To initiate a compute job, there are two main approaches you can take. The first method involves publishing both the dataset and algorithm, as detailed in the previous section Publish a dataset, and then proceeding to start the compute job. Alternatively, you can opt to explore available datasets and algorithms and initiate a compute-to-data job using a combination of your choice.
To demonstrate the latter option, you can utilize the following command: <code>npm run cli startCompute 'DATASET_DID' 'ALGO_DID'</code>.
In this command, 'DATASET_DID' should be replaced with the specific DID of the dataset you wish to employ, and 'ALGO_DID' with the DID of the algorithm you want to apply. By executing this command, you will trigger the initiation of a compute-to-data job that leverages the selected dataset and algorithm for processing.
<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzQlpIJEeu8x5yl0OLuXn%2Fuploads%2FMEY5XCfq5mW4Nm7mQlo9%2FScreenshot%202023-09-28%20at%2001.49.16.png?alt=media&token=30b0d80e-cc9b-43fb-a50e-66d7409c6b69" alt=""><figcaption>startCompute method example</figcaption></figure>

View File

@ -0,0 +1,11 @@
# Usage
The command <code>npm run cli h</code> returns a list of all commands and option flags.
<pre><code>```bash
#!/bin/bash
npm run cli h
```
</code></pre>
<figure><img src="https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FzQlpIJEeu8x5yl0OLuXn%2Fuploads%2FBCFAxxcCjwVPJfiKOOt1%2FScreenshot%202023-09-27%20at%2023.55.43.png?alt=media&token=76114c63-da9c-4d34-afdb-97b6bafca9d9" alt=""><figcaption></figcaption></figure>