Skip to content

Commit

Permalink
Changes to file structure (schema v4.1.0) (#856)
Browse files Browse the repository at this point in the history
* Correct pytest workflow.
* Add explanation for files length.
* Bump ocean-contracts to 1.0.0 and fix some tests.
* Fix disconnecting components test and remove todo.
* Use free c2d environment.
* Intermediary commit to set nftAddress in files encryption.
* Bubble 400 errors.
  • Loading branch information
calina-c authored Jun 16, 2022
1 parent 582f365 commit acd6129
Show file tree
Hide file tree
Showing 32 changed files with 585 additions and 520 deletions.
12 changes: 5 additions & 7 deletions READMEs/c2d-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ DATA_url_file = UrlFile(
url="https://raw.githubusercontent.com/oceanprotocol/c2d-examples/main/branin_and_gpr/branin.arff"
)

# Encrypt file(s) using provider
DATA_encrypted_files = ocean.assets.encrypt_files([DATA_url_file])
DATA_files = [DATA_url_file]

# Set the compute values for compute service
DATA_compute_values = {
Expand All @@ -96,7 +95,7 @@ DATA_compute_service = Service(
service_type="compute",
service_endpoint=ocean.config.provider_url,
datatoken=DATA_datatoken.address,
files=DATA_encrypted_files,
files=DATA_files,
timeout=3600,
compute_values=DATA_compute_values,
)
Expand All @@ -105,7 +104,7 @@ DATA_compute_service = Service(
DATA_asset = ocean.assets.create(
metadata=DATA_metadata,
publisher_wallet=alice_wallet,
encrypted_files=DATA_encrypted_files,
files=DATA_files,
services=[DATA_compute_service],
data_nft_address=data_nft.address,
deployed_datatokens=[DATA_datatoken],
Expand Down Expand Up @@ -157,15 +156,14 @@ ALGO_url_file = UrlFile(
url="https://raw.githubusercontent.com/oceanprotocol/c2d-examples/main/branin_and_gpr/gpr.py"
)

# Encrypt file(s) using provider
ALGO_encrypted_files = ocean.assets.encrypt_files([ALGO_url_file])
ALGO_files = [ALGO_url_file]

# Publish asset with compute service on-chain.
# The download (access service) is automatically created, but you can explore other options as well
ALGO_asset = ocean.assets.create(
metadata=ALGO_metadata,
publisher_wallet=alice_wallet,
encrypted_files=ALGO_encrypted_files,
files=ALGO_files,
data_nft_address=ALGO_nft_token.address,
deployed_datatokens=[ALGO_datatoken],
)
Expand Down
4 changes: 2 additions & 2 deletions READMEs/datatoken-enterprise.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Asset creation will be based on the deployment of Datatoken Enterprise token lik
asset = ocean.assets.create(
metadata,
alice_wallet,
encrypted_files,
[url_file],
deployed_datatokens=[datatoken_enterprise_token]
)
access_service = asset.services[0]
Expand Down Expand Up @@ -177,7 +177,7 @@ Asset creation will be based on the deployment of Datatoken Enterprise token lik
asset = ocean.assets.create(
metadata,
alice_wallet,
encrypted_files,
[url_file],
deployed_datatokens=[datatoken_enterprise_token]
)
access_service = asset.services[0]
Expand Down
6 changes: 1 addition & 5 deletions READMEs/publish-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,12 @@ url_file = UrlFile(
url="https://raw.githubusercontent.com/trentmc/branin/main/branin.arff"
)

# Encrypt file(s) using provider
encrypted_files = ocean.assets.encrypt_files([url_file])


# Publish asset with services on-chain.
# The download (access service) is automatically created, but you can explore other options as well
asset = ocean.assets.create(
metadata,
alice_wallet,
encrypted_files,
[url_file],
datatoken_templates=[1],
datatoken_names=["Datatoken 1"],
datatoken_symbols=["DT1"],
Expand Down
4 changes: 1 addition & 3 deletions ocean_lib/aquarius/test/test_aquarius.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ def test_aqua_functions_for_single_ddo(
"license": "https://market.oceanprotocol.com/terms",
}

encrypted_files = publisher_ocean_instance.assets.encrypt_files([file1])

ddo = publisher_ocean_instance.assets.create(
metadata=metadata,
publisher_wallet=publisher_wallet,
encrypted_files=encrypted_files,
files=[file1],
datatoken_templates=[1],
datatoken_names=["Datatoken 1"],
datatoken_symbols=["DT1"],
Expand Down
3 changes: 2 additions & 1 deletion ocean_lib/assets/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
self.chain_id = chain_id
self.nft_address = nft_address
self.metadata = metadata
self.version = "4.0.0"
self.version = "4.1.0"
self.services = services or []
self.credentials = credentials or {}
self.nft = nft
Expand Down Expand Up @@ -147,6 +147,7 @@ def add_service(self, service: Service) -> None:
:param service: To add service, Service
"""
service.encrypt_files(self.nft_address)

logger.debug(
f"Adding service with service type {service.type} with did {self.did}"
Expand Down
2 changes: 1 addition & 1 deletion ocean_lib/assets/test/test_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_asset_utils(web3):
== "did:op:68a7f03e59c70d59607e3f0a536ed4d32e0599db07f587d66bd1221573d38c21"
)
did = ddo_dict["id"]
assert ddo_dict["version"] == "4.0.0"
assert ddo_dict["version"] == "4.1.0"
assert ddo_dict["chainId"] == web3.eth.chain_id
chain_id = ddo_dict["chainId"]

Expand Down
4 changes: 2 additions & 2 deletions ocean_lib/assets/test/test_asset_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ def ocean_assets_download_destination_file_helper(
"""Downloading to an existing directory."""
data_provider = DataServiceProvider

_, metadata, encrypted_files = create_basics(config, web3, data_provider)
_, metadata, files = create_basics(config, web3, data_provider)
ddo = publisher_ocean_instance.assets.create(
metadata=metadata,
publisher_wallet=publisher_wallet,
encrypted_files=encrypted_files,
files=files,
data_nft_address=data_nft.address,
deployed_datatokens=[datatoken],
)
Expand Down
Loading

0 comments on commit acd6129

Please sign in to comment.