Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
env/
venv/
.env
.venv
.idea/
__pycache__
blockchain/node_modules
Expand Down
3 changes: 3 additions & 0 deletions packages/sdk/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
env/
venv/
.env
.venv
snet.sdk.egg-info/
build/
dist/
3 changes: 3 additions & 0 deletions packages/snet_cli/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.env
.venv
env/
venv/
snet_cli.egg-info/
snet.snet_cli.egg-info/
Expand Down
3 changes: 2 additions & 1 deletion packages/snet_cli/snet/snet_cli/utils/ipfs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def safe_extract_proto_from_ipfs(ipfs_client, ipfs_hash, protodir):
"tarball contains %s which is not a files" % m.name)
fullname = os.path.join(protodir, m.name)
if os.path.exists(fullname):
raise Exception("%s already exists." % fullname)
os.remove(fullname)
print("%s removed." % fullname)
# now it is safe to call extractall
f.extractall(protodir)
11 changes: 4 additions & 7 deletions packages/snet_cli/snet_cli/commands/sdk_command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
from pathlib import Path, PurePath
from tempfile import TemporaryDirectory

from snet.snet_cli.utils.ipfs_utils import safe_extract_proto_from_ipfs
from snet.snet_cli.utils.utils import compile_proto
Expand Down Expand Up @@ -28,13 +27,11 @@ def generate_client_library(self):
metadata = self._get_service_metadata_from_registry()
model_ipfs_hash = metadata["model_ipfs_hash"]

with TemporaryDirectory() as temp_dir:
temp_dir_path = PurePath(temp_dir)
proto_temp_dir_path = temp_dir_path.joinpath(library_org_id, library_service_id, library_language)
safe_extract_proto_from_ipfs(self._get_ipfs_client(), model_ipfs_hash, proto_temp_dir_path)
# Receive proto files
safe_extract_proto_from_ipfs(self._get_ipfs_client(), model_ipfs_hash, library_dir_path)

# Compile proto files
compile_proto(Path(proto_temp_dir_path), library_dir_path, target_language=self.args.language)
# Compile proto files
compile_proto(Path(library_dir_path), library_dir_path, target_language=self.args.language)

self._printout(
'client libraries for service with id "{}" in org with id "{}" generated at {}'.format(library_service_id,
Expand Down