Skip to content

Commit

Permalink
Merge branch 'oss-main' into clang-tidy-kv-pai-log-event
Browse files Browse the repository at this point in the history
  • Loading branch information
LinZhihao-723 committed Jan 5, 2025
2 parents dcbd0cf + 0ace191 commit 26bd164
Show file tree
Hide file tree
Showing 19 changed files with 94 additions and 85 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ jobs:
os: "macos-14"
- name: "cp312-macosx_x86_64"
os: "macos-14"
- name: "cp313-macosx_arm64"
os: "macos-14"
- name: "cp313-macosx_universal2"
os: "macos-14"
- name: "cp313-macosx_x86_64"
os: "macos-14"

# Linux builds
- name: "cp310-manylinux_aarch64"
Expand Down Expand Up @@ -131,6 +137,18 @@ jobs:
os: "ubuntu-22.04"
- name: "cp312-musllinux_x86_64"
os: "ubuntu-22.04"
- name: "cp313-manylinux_aarch64"
os: "ubuntu-22.04"
- name: "cp313-manylinux_i686"
os: "ubuntu-22.04"
- name: "cp313-manylinux_x86_64"
os: "ubuntu-22.04"
- name: "cp313-musllinux_aarch64"
os: "ubuntu-22.04"
- name: "cp313-musllinux_i686"
os: "ubuntu-22.04"
- name: "cp313-musllinux_x86_64"
os: "ubuntu-22.04"
- name: "cp37-manylinux_aarch64"
os: "ubuntu-22.04"
- name: "cp37-manylinux_i686"
Expand Down Expand Up @@ -181,6 +199,8 @@ jobs:
os: "windows-2022"
- name: "cp312-win_amd64"
os: "windows-2022"
- name: "cp313-win_amd64"
os: "windows-2022"

steps:
- name: "Checkout"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ project homepage on PyPI [here][7].

## Compatibility

Tested on Python 3.7, 3.8, 3.11 and 3.12, and it should work on any Python
Tested on Python 3.7, 3.8, 3.11, 3.12, and 3.13, and it should work on any Python
version >= 3.7.

## API Reference
Expand Down
3 changes: 1 addition & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
black>=24.4.2
build>=0.8.0
cibuildwheel>=2.16.2
# Lock to v18.x until we can upgrade our code to meet v19's formatting standards.
clang-format~=18.1
clang-format>=19.1.6
clang-tidy>=19.1.0
docformatter>=1.7.5
gersemi>=0.16.2
Expand Down
2 changes: 1 addition & 1 deletion src/clp_ffi_py/ExceptionFFI.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ExceptionFFI : public clp::TraceableException {
std::string message
)
: TraceableException{error_code, filename, line_number},
m_message{std::move(message)} {};
m_message{std::move(message)} {}

[[nodiscard]] auto what() const noexcept -> char const* override { return m_message.c_str(); }

Expand Down
11 changes: 5 additions & 6 deletions src/clp_ffi_py/Py_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,18 @@ namespace clp_ffi_py {
* @return a new reference of a PyObject string that stores the formatted timestamp.
* @return nullptr on failure with the relevant Python exception and error set.
*/
[[nodiscard]] auto py_utils_get_formatted_timestamp(
clp::ir::epoch_time_ms_t timestamp,
PyObject* timezone
) -> PyObject*;
[[nodiscard]] auto
py_utils_get_formatted_timestamp(clp::ir::epoch_time_ms_t timestamp, PyObject* timezone)
-> PyObject*;

/**
* CPython wrapper of `clp_ffi_py.utils.get_timezone_from_timezone_id`.
* @param timezone_id
* @return a new reference of a Python tzinfo object that matches the input timezone id.
* @return nullptr on failure with the relevant Python exception and error set.
*/
[[nodiscard]] auto py_utils_get_timezone_from_timezone_id(std::string const& timezone_id
) -> PyObject*;
[[nodiscard]] auto py_utils_get_timezone_from_timezone_id(std::string const& timezone_id)
-> PyObject*;

/**
* CPython wrapper of `clp_ffi_py.utils.serialize_dict_to_msgpack`.
Expand Down
2 changes: 1 addition & 1 deletion src/clp_ffi_py/ir/native/Metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Metadata {
: m_is_four_byte_encoding{true},
m_ref_timestamp{ref_timestamp},
m_timestamp_format{std::move(timestamp_format)},
m_timezone_id{std::move(timezone)} {};
m_timezone_id{std::move(timezone)} {}

[[nodiscard]] auto is_using_four_byte_encoding() const -> bool {
return m_is_four_byte_encoding;
Expand Down
8 changes: 4 additions & 4 deletions src/clp_ffi_py/ir/native/PyDeserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ PyDoc_STRVAR(
" treated as an error.\n"
":type allow_incomplete_stream: bool\n"
);
CLP_FFI_PY_METHOD auto
PyDeserializer_init(PyDeserializer* self, PyObject* args, PyObject* keywords) -> int;
CLP_FFI_PY_METHOD auto PyDeserializer_init(PyDeserializer* self, PyObject* args, PyObject* keywords)
-> int;

/**
* Callback of `PyDeserializer`'s `deserialize_log_event`.
Expand Down Expand Up @@ -105,8 +105,8 @@ PyType_Spec PyDeserializer_type_spec{
static_cast<PyType_Slot*>(PyDeserializer_slots)
};

CLP_FFI_PY_METHOD auto
PyDeserializer_init(PyDeserializer* self, PyObject* args, PyObject* keywords) -> int {
CLP_FFI_PY_METHOD auto PyDeserializer_init(PyDeserializer* self, PyObject* args, PyObject* keywords)
-> int {
static char keyword_input_stream[]{"input_stream"};
static char keyword_buffer_capacity[]{"buffer_capacity"};
static char keyword_allow_incomplete_stream[]{"allow_incomplete_stream"};
Expand Down
15 changes: 7 additions & 8 deletions src/clp_ffi_py/ir/native/PyDeserializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,14 @@ class PyDeserializer {
~IrUnitHandler() = default;

// Implements `clp::ffi::ir_stream::IrUnitHandlerInterface` interface
[[nodiscard]] auto handle_log_event(clp::ffi::KeyValuePairLogEvent&& log_event
) -> clp::ffi::ir_stream::IRErrorCode {
[[nodiscard]] auto handle_log_event(clp::ffi::KeyValuePairLogEvent&& log_event)
-> clp::ffi::ir_stream::IRErrorCode {
return m_log_event_handle(std::move(log_event));
}

[[nodiscard]] auto handle_utc_offset_change(
clp::UtcOffset utc_offset_old,
clp::UtcOffset utc_offset_new
) -> clp::ffi::ir_stream::IRErrorCode {
[[nodiscard]] auto
handle_utc_offset_change(clp::UtcOffset utc_offset_old, clp::UtcOffset utc_offset_new)
-> clp::ffi::ir_stream::IRErrorCode {
return m_utc_offset_change_handle(utc_offset_old, utc_offset_new);
}

Expand Down Expand Up @@ -201,8 +200,8 @@ class PyDeserializer {
* @return IRErrorCode::IRErrorCode_Success on success.
*
*/
[[nodiscard]] auto handle_log_event(clp::ffi::KeyValuePairLogEvent&& log_event
) -> clp::ffi::ir_stream::IRErrorCode;
[[nodiscard]] auto handle_log_event(clp::ffi::KeyValuePairLogEvent&& log_event)
-> clp::ffi::ir_stream::IRErrorCode;

/**
* @return Whether `m_deserialized_log_event` has been set.
Expand Down
4 changes: 2 additions & 2 deletions src/clp_ffi_py/ir/native/PyDeserializerBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ PyDoc_STRVAR(
":return: Total number of messages deserialized so far.\n"
);

auto PyDeserializerBuffer_get_num_deserialized_log_messages(PyDeserializerBuffer* self
) -> PyObject* {
auto PyDeserializerBuffer_get_num_deserialized_log_messages(PyDeserializerBuffer* self)
-> PyObject* {
return PyLong_FromLongLong(static_cast<long long>(self->get_num_deserialized_message()));
}

Expand Down
32 changes: 14 additions & 18 deletions src/clp_ffi_py/ir/native/PyKeyValuePairLogEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ namespace {
class IrUnitHandler {
public:
// Methods that implement the `clp::ffi::ir_stream::IrUnitHandlerInterface` interface
[[nodiscard]] auto handle_log_event(clp::ffi::KeyValuePairLogEvent&& deserialized_log_event
) -> IRErrorCode {
[[nodiscard]] auto handle_log_event(clp::ffi::KeyValuePairLogEvent&& deserialized_log_event)
-> IRErrorCode {
log_event.emplace(std::move(deserialized_log_event));
return IRErrorCode::IRErrorCode_Success;
}
Expand Down Expand Up @@ -247,11 +247,9 @@ PyDoc_STRVAR(
" must be strings, including keys inside any sub-dictionaries.\n"
":type dictionary: dict[str, Any]\n"
);
CLP_FFI_PY_METHOD auto PyKeyValuePairLogEvent_init(
PyKeyValuePairLogEvent* self,
PyObject* args,
PyObject* keywords
) -> int;
CLP_FFI_PY_METHOD auto
PyKeyValuePairLogEvent_init(PyKeyValuePairLogEvent* self, PyObject* args, PyObject* keywords)
-> int;

/**
* Callback of `PyKeyValuePairLogEvent`'s `to_dict` method.
Expand Down Expand Up @@ -319,8 +317,8 @@ PyType_Spec PyKeyValuePairLogEvent_type_spec{
* @return The converted key-value log event of the given dictionary on success.
* @return std::nullopt on failure with the relevant Python exception and error set.
*/
[[nodiscard]] auto convert_py_dict_to_key_value_pair_log_event(PyDictObject* py_dict
) -> std::optional<clp::ffi::KeyValuePairLogEvent>;
[[nodiscard]] auto convert_py_dict_to_key_value_pair_log_event(PyDictObject* py_dict)
-> std::optional<clp::ffi::KeyValuePairLogEvent>;

/**
* Serializes the given node id value pairs into a Python dictionary object.
Expand Down Expand Up @@ -360,11 +358,9 @@ PyType_Spec PyKeyValuePairLogEvent_type_spec{
*/
[[nodiscard]] auto decode_as_encoded_text_ast(Value const& val) -> std::optional<std::string>;

CLP_FFI_PY_METHOD auto PyKeyValuePairLogEvent_init(
PyKeyValuePairLogEvent* self,
PyObject* args,
PyObject* keywords
) -> int {
CLP_FFI_PY_METHOD auto
PyKeyValuePairLogEvent_init(PyKeyValuePairLogEvent* self, PyObject* args, PyObject* keywords)
-> int {
static char keyword_dictionary[]{"dictionary"};
static char* keyword_table[]{static_cast<char*>(keyword_dictionary), nullptr};

Expand Down Expand Up @@ -408,8 +404,8 @@ CLP_FFI_PY_METHOD auto PyKeyValuePairLogEvent_dealloc(PyKeyValuePairLogEvent* se
Py_TYPE(self)->tp_free(py_reinterpret_cast<PyObject>(self));
}

auto convert_py_dict_to_key_value_pair_log_event(PyDictObject* py_dict
) -> std::optional<clp::ffi::KeyValuePairLogEvent> {
auto convert_py_dict_to_key_value_pair_log_event(PyDictObject* py_dict)
-> std::optional<clp::ffi::KeyValuePairLogEvent> {
PyObjectPtr<PyBytesObject> const serialized_msgpack_byte_sequence{
py_utils_serialize_dict_to_msgpack(py_dict)
};
Expand Down Expand Up @@ -693,8 +689,8 @@ auto PyKeyValuePairLogEvent::init(clp::ffi::KeyValuePairLogEvent kv_pair_log_eve
}
}

auto PyKeyValuePairLogEvent::create(clp::ffi::KeyValuePairLogEvent kv_log_event
) -> PyKeyValuePairLogEvent* {
auto PyKeyValuePairLogEvent::create(clp::ffi::KeyValuePairLogEvent kv_log_event)
-> PyKeyValuePairLogEvent* {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-cstyle-cast)
PyKeyValuePairLogEvent* self{PyObject_New(PyKeyValuePairLogEvent, get_py_type())};
if (nullptr == self) {
Expand Down
4 changes: 2 additions & 2 deletions src/clp_ffi_py/ir/native/PyKeyValuePairLogEvent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class PyKeyValuePairLogEvent {
* given kv log event.
* @return nullptr on failure with the relevant Python exception and error set.
*/
[[nodiscard]] static auto create(clp::ffi::KeyValuePairLogEvent kv_log_event
) -> PyKeyValuePairLogEvent*;
[[nodiscard]] static auto create(clp::ffi::KeyValuePairLogEvent kv_log_event)
-> PyKeyValuePairLogEvent*;

/**
* Gets the `PyTypeObject` that represents `PyKeyValuePair`'s Python type. This type is
Expand Down
4 changes: 2 additions & 2 deletions src/clp_ffi_py/ir/native/PyMetadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class PyMetadata {
* @return true on success.
* @return false on failure with the relevant Python exception and error set.
*/
[[nodiscard]] auto
init(nlohmann::json const& metadata, bool is_four_byte_encoding = true) -> bool;
[[nodiscard]] auto init(nlohmann::json const& metadata, bool is_four_byte_encoding = true)
-> bool;

/**
* Releases the memory allocated for underlying metadata field and the reference hold for the
Expand Down
1 change: 0 additions & 1 deletion src/clp_ffi_py/ir/native/PyQuery.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#include <wrapped_facade_headers/Python.hpp> // Must be included before any other header files

#include "PyQuery.hpp"
Expand Down
38 changes: 18 additions & 20 deletions src/clp_ffi_py/ir/native/PySerializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ PyDoc_STRVAR(
" it to `output_stream`. Defaults to 64 KiB.\n"
":type buffer_size_limit: int\n"
);
CLP_FFI_PY_METHOD auto
PySerializer_init(PySerializer* self, PyObject* args, PyObject* keywords) -> int;
CLP_FFI_PY_METHOD auto PySerializer_init(PySerializer* self, PyObject* args, PyObject* keywords)
-> int;

/**
* Callback of `PySerializer`'s `serialize_msgpack` method.
Expand All @@ -64,10 +64,9 @@ PyDoc_STRVAR(
":raise RuntimeError: If `msgpack_map` couldn't be unpacked or serialization into the IR"
" stream failed.\n"
);
CLP_FFI_PY_METHOD auto PySerializer_serialize_log_event_from_msgpack_map(
PySerializer* self,
PyObject* msgpack_map
) -> PyObject*;
CLP_FFI_PY_METHOD auto
PySerializer_serialize_log_event_from_msgpack_map(PySerializer* self, PyObject* msgpack_map)
-> PyObject*;

/**
* Callback of `PySerializer`'s `get_num_bytes_serialized` method.
Expand Down Expand Up @@ -140,8 +139,8 @@ PyDoc_STRVAR(
":param exc_value: The value of the exception that caused the exit. Unused.\n"
":param exc_traceable: The traceback. Unused.\n"
);
CLP_FFI_PY_METHOD auto
PySerializer_exit(PySerializer* self, PyObject* args, PyObject* keywords) -> PyObject*;
CLP_FFI_PY_METHOD auto PySerializer_exit(PySerializer* self, PyObject* args, PyObject* keywords)
-> PyObject*;

/**
* Callback of `PySerializer`'s deallocator.
Expand Down Expand Up @@ -206,8 +205,8 @@ PyType_Spec PySerializer_type_spec{
static_cast<PyType_Slot*>(PySerializer_slots)
};

CLP_FFI_PY_METHOD auto
PySerializer_init(PySerializer* self, PyObject* args, PyObject* keywords) -> int {
CLP_FFI_PY_METHOD auto PySerializer_init(PySerializer* self, PyObject* args, PyObject* keywords)
-> int {
static char keyword_output_stream[]{"output_stream"};
static char keyword_buffer_size_limit[]{"buffer_size_limit"};
static char* keyword_table[]{
Expand Down Expand Up @@ -286,10 +285,9 @@ PySerializer_init(PySerializer* self, PyObject* args, PyObject* keywords) -> int
return 0;
}

CLP_FFI_PY_METHOD auto PySerializer_serialize_log_event_from_msgpack_map(
PySerializer* self,
PyObject* msgpack_map
) -> PyObject* {
CLP_FFI_PY_METHOD auto
PySerializer_serialize_log_event_from_msgpack_map(PySerializer* self, PyObject* msgpack_map)
-> PyObject* {
if (false == static_cast<bool>(PyBytes_Check(msgpack_map))) {
PyErr_SetString(
PyExc_TypeError,
Expand Down Expand Up @@ -334,8 +332,8 @@ CLP_FFI_PY_METHOD auto PySerializer_enter(PySerializer* self) -> PyObject* {
return py_reinterpret_cast<PyObject>(self);
}

CLP_FFI_PY_METHOD auto
PySerializer_exit(PySerializer* self, PyObject* args, PyObject* keywords) -> PyObject* {
CLP_FFI_PY_METHOD auto PySerializer_exit(PySerializer* self, PyObject* args, PyObject* keywords)
-> PyObject* {
static char keyword_exc_type[]{"exc_type"};
static char keyword_exc_value[]{"exc_value"};
static char keyword_traceback[]{"traceback"};
Expand Down Expand Up @@ -426,8 +424,8 @@ auto PySerializer::assert_is_not_closed() const -> bool {
return true;
}

auto PySerializer::serialize_log_event_from_msgpack_map(std::span<char const> msgpack_byte_sequence
) -> std::optional<Py_ssize_t> {
auto PySerializer::serialize_log_event_from_msgpack_map(std::span<char const> msgpack_byte_sequence)
-> std::optional<Py_ssize_t> {
if (false == assert_is_not_closed()) {
return std::nullopt;
}
Expand Down Expand Up @@ -529,8 +527,8 @@ auto PySerializer::write_ir_buf_to_output_stream() -> bool {
return true;
}

auto PySerializer::write_to_output_stream(PySerializer::BufferView buf
) -> std::optional<Py_ssize_t> {
auto PySerializer::write_to_output_stream(PySerializer::BufferView buf)
-> std::optional<Py_ssize_t> {
if (buf.empty()) {
return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/clp_ffi_py/ir/native/Query.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class WildcardQuery {
*/
WildcardQuery(std::string wildcard_query, bool case_sensitive)
: m_wildcard_query(std::move(wildcard_query)),
m_case_sensitive(case_sensitive) {};
m_case_sensitive(case_sensitive) {}

[[nodiscard]] auto get_wildcard_query() const -> std::string const& { return m_wildcard_query; }

Expand Down Expand Up @@ -69,7 +69,7 @@ class Query {
explicit Query()
: m_lower_bound_ts{cTimestampMin},
m_upper_bound_ts{cTimestampMax},
m_search_termination_ts{cTimestampMax} {};
m_search_termination_ts{cTimestampMax} {}

/**
* Constructs a new query object with the given timestamp range with an empty wildcard list.
Expand Down
7 changes: 3 additions & 4 deletions src/clp_ffi_py/ir/native/deserialization_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,9 @@ concept TerminateHandlerSignature = requires(TerminateHandler handler) {
* @param nullptr if the IR stream is incomplete not allowed, with the relevant Python exceptions
* and error set.
*/
[[nodiscard]] auto handle_incomplete_ir_error(
PyDeserializerBuffer* deserializer_buffer,
bool allow_incomplete_stream
) -> std::optional<PyObject*> {
[[nodiscard]] auto
handle_incomplete_ir_error(PyDeserializerBuffer* deserializer_buffer, bool allow_incomplete_stream)
-> std::optional<PyObject*> {
if (deserializer_buffer->try_read()) {
return std::nullopt;
}
Expand Down
Loading

0 comments on commit 26bd164

Please sign in to comment.