Commit 5b2745c5 authored by Samuel GAIST's avatar Samuel GAIST Committed by Amir MOHAMMADI

[common] Implement push and pull of binary algorithm data

parent ba1d6548
......@@ -862,7 +862,25 @@ def pull(webapi, prefix, asset_type, names, fields, force, indentation):
}
storage.save(declaration)
else:
if asset_type == "algorithm" and storage.language == "cxx":
try:
file_data = webapi.download(
"/api/v1/%s/%s/%s/%s/file/"
% (
TYPE_PLURAL[asset_type],
webapi.user,
storage.name,
storage.version,
)
)
data["code"] = file_data
except Exception as e:
logger.error(e)
status += 1
continue
storage.save(**data)
available.add(name)
return status, list(available)
......@@ -1470,7 +1488,7 @@ def push(
# C++ algorithms must be sent in two steps (see below)
if asset_type == "algorithm" and storage.language == "cxx":
cxx_code = message.pop("code")
message.pop("code")
# sends the data
if (
......@@ -1511,11 +1529,27 @@ def push(
# C++ algorithms must be sent in two steps, we send the binary file now
if asset_type == "algorithm" and storage.language == "cxx":
webapi.post_v2(
f"/api/v1/{TYPE_PLURAL[asset_type]}/{webapi.user}/{storage.name}/{storage.version}/binary/",
data=cxx_code,
extra_header={"Content-Type": "application/octet-stream"},
)
try:
webapi.upload(
"/api/v1/%s/%s/%s/%s/file/"
% (
TYPE_PLURAL[asset_type],
webapi.user,
storage.name,
storage.version,
),
{
"binary": (
"%s.so" % storage.version,
open(storage.code.path, "rb"),
)
},
)
except RuntimeError as e:
logger.error(e)
return 1
else:
logger.info("Successfuly uploaded binary blob `%s'", asset_name)
return 0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment