Skip to content

Commit

Permalink
#16: bindings: Add a bit more functionality to binded function
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrepebay committed Nov 11, 2023
1 parent 4d69e0b commit 16bb9a6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions bindings/python/tv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace vt::tv::bindings::python {
void tv_from_json(const std::string& input_json_str, const std::string& input_yaml_params_str) {
auto j = nlohmann::json::parse(input_json_str);
fmt::print("JSON: {}\n", j.dump(2));
YAML::Node config = YAML::Load(input_yaml_params_str);
// Read the json file
// using json = nlohmann::json;

Expand Down
3 changes: 2 additions & 1 deletion bindings/python/tv.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@
#include "vt-tv/utility/input_iterator.h"

#include <nlohmann/json.hpp>
#include <nanobind/nanobind.h>
#include <yaml-cpp/yaml.h>

#include <nanobind/nanobind.h>
#include <nanobind/stl/string.h>

namespace vt::tv::bindings::python {
Expand Down
3 changes: 0 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ def build_extension(self, ext):
self.spawn(['cmake', ext.sourcedir] + cmake_args)
if not self.dry_run:
self.spawn(['cmake', '--build', '.', '--parallel', '-j8'] + build_args)
# # Returning to the previous directory
# print(self.distribution.get_fullname())
# os.chdir(self.distribution.get_fullname())


setup(
Expand Down
19 changes: 19 additions & 0 deletions testvttv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import json
import yaml
import vttv

with open('/Users/pierrepebay/Develop/vt-tv/tests/unit/lb_test_data/data.0.json') as f:
data = json.load(f)


with open("/Users/pierrepebay/Develop/vt-tv/config/conf.yaml", "r") as stream:
try:
params = yaml.safe_load(stream)
except yaml.YAMLError as exc:
print(exc)


data_serialized = json.dumps(data)
params_serialized = yaml.dump(params)

vttv.tv_from_json(data_serialized, params_serialized)

0 comments on commit 16bb9a6

Please sign in to comment.