Skip to content

Commit

Permalink
feat: Port over updated clang-format script from the reinforcement_le…
Browse files Browse the repository at this point in the history
…arning repo (VowpalWabbit#3992)

* Updated clang-format.sh script and run formatting. Changed header include order for vw_string_view_fmt.h to fix compile error.

* Undo clang-format on CSharp binding files due to compile errors

Co-authored-by: Jack Gerrits <[email protected]>
  • Loading branch information
byronxu99 and jackgerrits authored Jun 30, 2022
1 parent bbcfb7d commit 2dd3e03
Show file tree
Hide file tree
Showing 68 changed files with 652 additions and 618 deletions.
4 changes: 4 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ IndentPPDirectives: AfterHash
PointerAlignment: Left
DerivePointerAlignment: false
IncludeCategories:
# vw_string_format.h has a template specialization for fmt.h
# and it must be included first to prevent compile errors
- Regex: '"vw\/core\/vw_string_view_fmt\.h"'
Priority: 0
# First block is local directory includes
- Regex: '"[[:alnum:]._\/]+"'
Priority: 1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
clang-format --version
- name: Check code formatting for codebase
shell: bash
run: ./utl/clang-format check
run: ./utl/clang-format.sh check
env:
GH_WORKFLOW_LOGGING: true
- name: Check code formatting for diff
Expand Down
1 change: 1 addition & 0 deletions bindings/c/src/placeholder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
// license as described in the file LICENSE.

#include "vw/experimental/placeholder.h"

#include "vw/experimental/workspace.h"
4 changes: 2 additions & 2 deletions bindings/c/test/placeholder_test.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <boost/test/unit_test.hpp>

#include "vw/experimental/placeholder.h"

#include <boost/test/unit_test.hpp>

BOOST_AUTO_TEST_CASE(placeholder_test) {}
6 changes: 2 additions & 4 deletions java/src/main/c++/jni_base_learner.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ T base_predict(JNIEnv* env, example* ex, bool learn, VW::workspace* vwInstance,
else
vwInstance->predict(*ex);

if (predict)
result = predictor(ex, env);
if (predict) result = predictor(ex, env);

vwInstance->finish_example(*ex);
}
Expand Down Expand Up @@ -60,8 +59,7 @@ T base_predict(JNIEnv* env, jobjectArray example_strings, jboolean learn, jlong
jstring example_string = (jstring)(env->GetObjectArrayElement(example_strings, i));
example* ex = read_example(env, example_string, vwInstance);
ex_coll.push_back(ex);
if (i == 0)
first_example = ex;
if (i == 0) first_example = ex;
}
env->DeleteLocalRef(example_strings);

Expand Down
18 changes: 9 additions & 9 deletions java/src/main/c++/jni_spark_cluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "vw/spanning_tree/spanning_tree.h"

JNIEXPORT jlong JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_create(
JNIEnv *env, jclass, jint port, jboolean quiet)
JNIEnv* env, jclass, jint port, jboolean quiet)
{
try
{
Expand All @@ -16,9 +16,9 @@ JNIEXPORT jlong JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_create(
}
}

JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_delete(JNIEnv *env, jobject clusterObj)
JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_delete(JNIEnv* env, jobject clusterObj)
{
auto tree = (VW::SpanningTree *)get_native_pointer(env, clusterObj);
auto tree = (VW::SpanningTree*)get_native_pointer(env, clusterObj);

try
{
Expand All @@ -30,9 +30,9 @@ JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_delete(JN
}
}

JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_start(JNIEnv *env, jobject clusterObj)
JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_start(JNIEnv* env, jobject clusterObj)
{
auto tree = (VW::SpanningTree *)get_native_pointer(env, clusterObj);
auto tree = (VW::SpanningTree*)get_native_pointer(env, clusterObj);

try
{
Expand All @@ -44,9 +44,9 @@ JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_start(JNI
}
}

JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_stop(JNIEnv *env, jobject clusterObj)
JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_stop(JNIEnv* env, jobject clusterObj)
{
auto tree = (VW::SpanningTree *)get_native_pointer(env, clusterObj);
auto tree = (VW::SpanningTree*)get_native_pointer(env, clusterObj);

try
{
Expand All @@ -58,9 +58,9 @@ JNIEXPORT void JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_stop(JNIE
}
}

JNIEXPORT jint JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_getPort(JNIEnv *env, jobject clusterObj)
JNIEXPORT jint JNICALL Java_org_vowpalwabbit_spark_ClusterSpanningTree_getPort(JNIEnv* env, jobject clusterObj)
{
auto tree = (VW::SpanningTree *)get_native_pointer(env, clusterObj);
auto tree = (VW::SpanningTree*)get_native_pointer(env, clusterObj);

try
{
Expand Down
12 changes: 6 additions & 6 deletions java/src/main/c++/jni_spark_vw.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class StringGuard
jstring _source;
const char* _cstr;

public:
public:
StringGuard(JNIEnv* env, jstring source);
~StringGuard();

Expand All @@ -24,7 +24,7 @@ class CriticalArrayGuard
jarray _arr;
void* _arr0;

public:
public:
CriticalArrayGuard(JNIEnv* env, jarray arr);
~CriticalArrayGuard();

Expand All @@ -34,9 +34,9 @@ class CriticalArrayGuard
// bind VW instance and example together to reduce the number of variables passed around
class VowpalWabbitExampleWrapper
{
public:
VW::workspace* _all;
example* _example;
public:
VW::workspace* _all;
example* _example;

VowpalWabbitExampleWrapper(VW::workspace* all, example* example) : _all(all), _example(example) {}
VowpalWabbitExampleWrapper(VW::workspace* all, example* example) : _all(all), _example(example) {}
};
Loading

0 comments on commit 2dd3e03

Please sign in to comment.