Skip to content

Commit

Permalink
Issue509 fix readmes to use ExampleConfig (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Hunt-Mateo authored Sep 28, 2021
1 parent 60d02d9 commit 178b0c3
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 42 deletions.
32 changes: 10 additions & 22 deletions READMEs/c2d-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,35 +71,22 @@ pip install numpy
pip install matplotlib
```

### Create config file

In the work console:
```console
#Create config.ini file and fill it with configuration info
echo """
[eth-network]
network = http://127.0.0.1:8545
address.file = ~/.ocean/ocean-contracts/artifacts/address.json

[resources]
metadata_cache_uri = http://localhost:5000
provider.url = http://localhost:8030
provider.address = 0x00bd138abd70e2f00903268f3db08f2d25677c9e

downloads.path = consume-downloads
""" > config.ini
```

### Set envvars

In the work console:
```console
#set private keys of two accounts
export TEST_PRIVATE_KEY1=0x5d75837394b078ce97bc289fa8d75e21000573520bfa7784a9d28ccaae602bf8
export TEST_PRIVATE_KEY2=0xef4b441145c1d0f3b4bc6d61d29f5c6e502359481152f869247c7a4244d45209

#set the address file only for ganache
export ADDRESS_FILE=~/.ocean/ocean-contracts/artifacts/address.json

#set network URL
export OCEAN_NETWORK_URL=http://127.0.0.1:8545
```

### Config in Python
### Start Python

In the work console:
```console
Expand All @@ -111,12 +98,13 @@ For the following steps, we use the Python console. Keep it open between steps.
In the Python console:
```python
#create ocean instance
from ocean_lib.config import Config
from ocean_lib.example_config import ExampleConfig
from ocean_lib.ocean.ocean import Ocean
config = Config('config.ini')
config = ExampleConfig.get_config()
ocean = Ocean(config)

print(f"config.network_url = '{config.network_url}'")
print(f"config.block_confirmations = {config.block_confirmations.value}")
print(f"config.metadata_cache_uri = '{config.metadata_cache_uri}'")
print(f"config.provider_url = '{config.provider_url}'")

Expand Down
22 changes: 8 additions & 14 deletions READMEs/datatokens-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,6 @@ docker system prune -a --volumes
./start_ocean.sh --with-provider2
```

## Create config file

In a console:
```console
#Create config.ini file and fill it with configuration info
echo """
[eth-network]
network = http://127.0.0.1:8545
address.file = ~/.ocean/ocean-contracts/artifacts/address.json
""" > config.ini
```

## Install the library, set envvars

In a new console:
Expand All @@ -57,6 +45,12 @@ pip install ocean-lib
#set envvars
export TEST_PRIVATE_KEY1=0xc594c6e5def4bab63ac29eed19a134c130388f74f019bc74b8f4389df2837a58

#set the address file only for ganache
export ADDRESS_FILE=~/.ocean/ocean-contracts/artifacts/address.json

#set network URL
export OCEAN_NETWORK_URL=http://127.0.0.1:8545

#go into python
python
```
Expand All @@ -67,12 +61,12 @@ In the Python console:

```python
import os
from ocean_lib.config import Config
from ocean_lib.example_config import ExampleConfig
from ocean_lib.ocean.ocean import Ocean
from ocean_lib.web3_internal.wallet import Wallet

private_key = os.getenv('TEST_PRIVATE_KEY1')
config = Config('config.ini')
config = ExampleConfig.get_config()
ocean = Ocean(config)

print("create wallet: begin")
Expand Down
1 change: 1 addition & 0 deletions READMEs/dispenser-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ config = ExampleConfig.get_config()
ocean = Ocean(config)

print(f"config.network_url = '{config.network_url}'")
print(f"config.block_confirmations = {config.block_confirmations.value}")
print(f"config.metadata_cache_uri = '{config.metadata_cache_uri}'")
print(f"config.provider_url = '{config.provider_url}'")
print(f"config.network_name = '{config.network_name}'")
Expand Down
1 change: 1 addition & 0 deletions READMEs/fixed-rate-exchange-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ config = ExampleConfig.get_config()
ocean = Ocean(config)

print(f"config.network_url = '{config.network_url}'")
print(f"config.block_confirmations = {config.block_confirmations.value}")
print(f"config.metadata_cache_uri = '{config.metadata_cache_uri}'")
print(f"config.provider_url = '{config.provider_url}'")

Expand Down
4 changes: 2 additions & 2 deletions READMEs/get-test-OCEAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ In a Python console:

```python
#setup
import os
from ocean_lib.example_config import ExampleConfig
from ocean_lib.ocean.ocean import Ocean
config = {'network': os.getenv('OCEAN_NETWORK_URL')}
config = ExampleConfig.get_config()
ocean = Ocean(config)

#create an ERC20 object of OCEAN token
Expand Down
4 changes: 2 additions & 2 deletions READMEs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ quick overview of the main functions and submodules:

```python
from ocean_lib.ocean.ocean import Ocean
from ocean_lib.config import Config
from ocean_lib.example_config import ExampleConfig

config = Config('config.ini')
config = ExampleConfig.get_config()

# Ocean instance: create/get datatoken, get dtfactory, user orders (history)
ocean = Ocean(config)
Expand Down
2 changes: 1 addition & 1 deletion READMEs/services.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ In your working directory, create a file `config.ini` and fill it with the follo
network = https://rinkeby.infura.io/v3/<your Infura project id>

[resources]
metadata_cache_uri = https://aquarius.rinkeby.oceanprotocol.com
metadata_cache_uri = https://aquarius.oceanprotocol.com
provider.url = https://provider.rinkeby.oceanprotocol.com

Ensure that envvars don't override the config file values:
Expand Down
1 change: 1 addition & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

network = http://127.0.0.1:8545
address.file = ~/.ocean/ocean-contracts/artifacts/address.json
block_confirmations = 0


[resources]
Expand Down
1 change: 0 additions & 1 deletion ocean_lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@

SECTION_ETH_NETWORK = "eth-network"
SECTION_RESOURCES = "resources"
SECTION_UTIL = "util"

environ_names_and_sections = {
NAME_DATA_TOKEN_FACTORY_ADDRESS: [
Expand Down

0 comments on commit 178b0c3

Please sign in to comment.