-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 83: Enable Python bindings for StreamManager and EventWriter. #104
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
5d05198
fix tokio dependency.
shrids 1faeaa2
pyo3 requires nightly.
shrids ab9b055
Add pyo3 dependency.
shrids daa2c59
ensure rlib is also generated for the cli.
shrids f132125
Fix cdylib issue .
shrids 603299b
First version of the python apis.
shrids 40bd4eb
First version of event writer. Improve StreamManager apis.
shrids ad60ecc
Add test python file.
shrids c07dc0a
Update git ignore for python files
shrids d21570d
Implement a Python __repr__ function
shrids 130f12e
Improve POC.
shrids 0b0af9e
Ensure github flows uses nightly.
shrids 998f8aa
Enable Byte array as a parameter for Python apis.
shrids d31f3cd
Cargo test fails for bindings.
shrids 36f7428
CR Changes.
shrids 224a617
remove redundant main
shrids 9398fb8
fix clippy.
shrids 8c3a680
Fix clippy errors.
shrids 259e4ab
Remove comment.
shrids File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,6 @@ pravega-*.tgz | |
.vscode | ||
/shared/target/ | ||
.gradle | ||
*.log | ||
|
||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ version = "0.1.0" | |
edition = "2018" | ||
categories = ["Network programming"] | ||
keywords = ["streaming", "client", "pravega"] | ||
readme = "Readme.md" | ||
readme = "README.md" | ||
repository = "https://github.com/pravega/pravega-client-rust" | ||
license = "Apache-2.0" | ||
description = "A Rust client for Pravega. (Pravega.io)" | ||
|
@@ -15,7 +15,7 @@ authors = ["Tom Kaitchuck <[email protected]>", "Wenqi Mou <wenqi.mou@dell. | |
|
||
[workspace] | ||
members = [ | ||
"controller-client", "shared", "wire_protocol", "retry", "integration_test", "connection_pool", "channel", | ||
"controller-client", "shared", "wire_protocol", "retry", "integration_test", "connection_pool", "channel", "bindings" | ||
] | ||
|
||
[dependencies] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[package] | ||
name = "pravega-rust-client-bindings" | ||
version = "0.1.0" | ||
edition = "2018" | ||
categories = ["Network programming"] | ||
keywords = ["streaming", "client", "pravega"] | ||
readme = "Readme.md" | ||
repository = "https://github.com/pravega/pravega-client-rust" | ||
license = "Apache-2.0" | ||
description = "An internal library used by the Rust client for Pravega to generated language bindings for Python and WASM." | ||
authors = ["Tom Kaitchuck <[email protected]>", "Wenqi Mou <[email protected]>", | ||
"Sandeep Shridhar <[email protected]>", "Wenxiao Zhang <[email protected]>"] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[lib] | ||
name = "pravega_client" | ||
crate-type = ["cdylib"] | ||
|
||
[features] | ||
default = ["python_binding"] | ||
javascript_binding = ["wasm-bindgen"] | ||
python_binding = ["pyo3"] | ||
|
||
#Run tests for bindings using command cargo test --no-default-features | ||
|
||
[dependencies] | ||
log = "0.4" | ||
pravega-client-rust = { path = "../" } | ||
pravega-wire-protocol = { path = "../wire_protocol"} | ||
pravega-controller-client = { path = "../controller-client"} | ||
pravega-rust-client-shared = { path = "../shared"} | ||
pravega-rust-client-retry = {path = "../retry"} | ||
pravega-connection-pool = {path= "../connection_pool"} | ||
tokio = { version = "0.2.13", features = ["full"] } | ||
lazy_static = "1.4.0" | ||
uuid = {version = "0.8", features = ["v4"]} | ||
futures = "0.3.5" | ||
derive-new = "0.5" | ||
#Python bindings | ||
pyo3 = { features = ["extension-module"], optional = true, version = "0.10.1" } | ||
#WASM bindings | ||
wasm-bindgen = { version = "0.2.63", optional = true } | ||
cfg-if = "0.1.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Language Bindings | ||
|
||
This provides a way to generate multiple language bindings to interact with Pravega. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
requires = ["maturin"] | ||
build-backend = "maturin" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
|
||
#[macro_use] | ||
extern crate cfg_if; | ||
|
||
mod stream_manager; | ||
mod stream_writer; | ||
cfg_if! { | ||
if #[cfg(feature = "python_binding")] { | ||
use pyo3::prelude::*; | ||
use stream_manager::StreamManager; | ||
#[macro_use] | ||
extern crate derive_new; | ||
use stream_writer::StreamWriter; | ||
} | ||
} | ||
|
||
#[cfg(feature = "python_binding")] | ||
#[pymodule] | ||
/// A Python module implemented in Rust. | ||
fn pravega_client(_py: Python, m: &PyModule) -> PyResult<()> { | ||
m.add_class::<StreamManager>()?; | ||
m.add_class::<StreamWriter>()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# Copyright (c) Dell Inc., or its subsidiaries. All Rights Reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
|
||
import unittest | ||
import pravega_client; | ||
|
||
class PravegaTest(unittest.TestCase): | ||
def test_writeEvent(self): | ||
print("Creating a Stream Manager, ensure pravega is running") | ||
stream_manager=pravega_client.StreamManager("127.0.0.1:9090") | ||
|
||
print("Creating a scope") | ||
scope_result=stream_manager.create_scope("testScope") | ||
self.assertEqual(True, scope_result, "Scope creation status") | ||
|
||
print("Creating a stream") | ||
stream_result=stream_manager.create_stream("testScope", "testStream", 1) | ||
self.assertEqual(True, stream_result, "Stream creation status") | ||
|
||
print("Creating a writer for Stream") | ||
w1=stream_manager.create_writer("testScope","testStream") | ||
|
||
print("Write events") | ||
w1.write_event("test event1") | ||
w1.write_event("test event2") | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably add a dummy main to keep the test suite happy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tried with a dummy main, it too fails. We need to use the workaround mentioined @ https://pyo3.rs/master/advanced.html#testing