Skip to content

Commit

Permalink
add rtaa services
Browse files Browse the repository at this point in the history
  • Loading branch information
andefined committed Aug 30, 2022
1 parent 4227ce8 commit 1d7df90
Show file tree
Hide file tree
Showing 47 changed files with 612 additions and 3,292 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REGISTRY=reg.cvcio.org
REPO=github.com/cvcio/proto

BUF_VERSION:=1.0.0-rc6
BUF_VERSION:=1.7.0

generate:
buf generate
Expand Down
15 changes: 2 additions & 13 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,8 @@ managed:
default: github.com/cvcio/mediawatch/internal
except:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
- buf.build/srikrsna/protoc-gen-gotag
plugins:
- name: go
out: internal
opt: paths=source_relative
- name: go-grpc
out: internal
opt:
- paths=source_relative
- require_unimplemented_servers=false
- name: grpc-gateway
out: internal
opt:
- paths=source_relative
- generate_unbound_methods=true
- name: openapiv2
out: swagger
14 changes: 6 additions & 8 deletions buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
branch: main
commit: c97f6fbd2f074e52b5c83baf8f740d42
digest: b1-tU-gRzsfP9s9EQG07Kq9cHZ_jkUGVeF9ArLCqzN7Nks=
create_time: 2021-11-30T15:07:54.995967Z
commit: 80720a488c9a414bb8d4a9f811084989
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
branch: main
commit: ff83506eb9cc4cf8972f49ce87e6ed3e
digest: b1-iLPHgLaoeWWinMiXXqPnxqE4BThtY3eSbswVGh9GOGI=
create_time: 2021-10-23T16:26:52.283938Z
commit: 00116f302b12478b85deb33b734e026c
- remote: buf.build
owner: srikrsna
repository: protoc-gen-gotag
commit: 04b38c6f540d4d2fa9cfd49ae01ae73b
3 changes: 2 additions & 1 deletion buf.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
version: v1
name: buf.build/andefined/protos
name: buf.build/cvcio/protos
deps:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
- buf.build/srikrsna/protoc-gen-gotag
lint:
use:
- DEFAULT
Expand Down
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ go 1.16

require (
github.com/amsokol/protoc-gen-gotag v0.2.1
github.com/bold-commerce/protoc-gen-struct-transformer v1.0.7
github.com/fatih/structtag v1.2.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0
go.buf.build/library/go/grpc-ecosystem/grpc-gateway v1.2.39 // indirect
google.golang.org/genproto v0.0.0-20210701191553-46259e63a0a9
google.golang.org/grpc v1.38.0
github.com/lyft/protoc-gen-star v0.6.1 // indirect
google.golang.org/genproto v0.0.0-20210701191553-46259e63a0a9 // indirect
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0
google.golang.org/protobuf v1.27.1
)
56 changes: 54 additions & 2 deletions go.sum

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions proto/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: v1
lint:
use:
- DEFAULT
breaking:
use:
- FILE
3 changes: 2 additions & 1 deletion proto/cvcio/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ breaking:
deps:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
- buf.build/gogo/protobuf
- buf.build/gogo/protobuf
- buf.build/srikrsna/protoc-gen-gotag
50 changes: 17 additions & 33 deletions proto/cvcio/classification/accounts.proto
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,45 @@ syntax = "proto3";
package classification;

// golang options
option go_package = "github.com/cvcio/proto/internal/classification";
// option go_package = "github.com/cvcio/proto/internal/classification";

import "google/api/annotations.proto";
import "google/protobuf/timestamp.proto";

import "proto/cvcio/classification/meta.proto";
import "proto/cvcio/classification/predictions.proto";

/**
TwitterAccount message holds information of the requested account
Required Fields
- followers (int64) as provided by Twitter API
- friends (int64) as provided by Twitter API
- statuses (int64) as provided by Twitter API
- lists (int64) as provided by Twitter API
Optional Fields
If optional fields missing we will try to calculate the values if available
In case of missing favorites (count) we will use the v2 account classifier
- favorites (int64) as provided by Twitter API
- ffr (double) calculated as: followers / firends
- stfv (double) calculated as: statuses / favorites
- stf (double) calculated as: statuses / favorites
- fvfr (double) calculated as: favorites / firends
- fl (double) calculated as: followers / lists
- dates (double) calculated as: followers / firends
- actions (double) calculated as: (statuses + favorites) / dates
Meta: Meta message (see proto/cvcio/common/meta)
- dates_since (float64) created date (as provided by Twitter API) - observed date (now)
**/
message TwitterAccount {
int64 followers = 1;
int64 friends = 2;
int64 statuses = 3;
int64 following = 2;
int64 tweets = 3;
int64 favorites = 4;
int64 lists = 5;
double ffr = 6;
double stfv = 7;
double stf = 8;
double fvfr = 9;
double fl = 10;
double dates = 11;
double actions = 12;
common.Meta meta = 13;
int64 listed = 5;

bool default_profile = 6;
bool verified = 7;

google.protobuf.Timestamp created_at = 8;

classification.Meta meta = 9;
}
// TwitterAccountList, a list of TwitterAccount messages {accounts: [...]}
message TwitterAccountList {
repeated TwitterAccount accounts = 1;
}
// ResponseAccount
// ResponseAccount
message ResponseAccount {
repeated common.Prediction predictions = 1;
repeated classification.Prediction predictions = 1;
}
// ResponseAccountList, a list of ResponseAccount messages {accounts: [...]}
message ResponseAccountList {
Expand All @@ -66,7 +50,7 @@ message ResponseAccountList {

// AccountService Microservice
service AccountService {
// ClassifyTwitterAccount classifies a single TwitterAccount
// ClassifyTwitterAccount classifies a single TwitterAccount
// returns a ResponseAccount message
rpc ClassifyTwitterAccount (TwitterAccount) returns (ResponseAccount) {
option (google.api.http) = {
Expand All @@ -82,4 +66,4 @@ service AccountService {
body : "*"
};
};
};
};
10 changes: 5 additions & 5 deletions proto/cvcio/classification/comments.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax = "proto3";

package classification;
option go_package = "github.com/cvcio/proto/internal/classification";
// option go_package = "github.com/cvcio/proto/internal/classification";

import "google/api/annotations.proto";

Expand All @@ -10,16 +10,16 @@ import "proto/cvcio/classification/predictions.proto";

message Comment {
string text = 1;
common.Meta meta = 2;
classification.Meta meta = 2;
}

message CommentList {
repeated Comment comments = 1;
}

message ResponseToxic {
repeated common.Prediction predictions = 1;
common.Meta meta = 2;
repeated classification.Prediction predictions = 1;
classification.Meta meta = 2;
}

message ResponseToxicList {
Expand All @@ -39,4 +39,4 @@ service CommentService {
body : "*"
};
};
};
};
14 changes: 5 additions & 9 deletions proto/cvcio/classification/meta.proto
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
syntax = "proto3";

package common;

// golang options
option go_package = "github.com/cvcio/proto/internal/common";
package classification;

import "google/protobuf/timestamp.proto";
import "proto/third_party/tagger/tagger.proto";

// Meta message holds metadata for any user request (comments or accounts classification)
// Use @ threshold to adjust the probability boundary (default 0.5)
Expand All @@ -15,11 +11,11 @@ message Meta {
string id = 1;
string source = 2;
string screen_name = 3;
google.protobuf.Timestamp comment_created_at = 4 [(tagger.tags) = "json:\"comment_created_at,omitempty\"" ];
google.protobuf.Timestamp user_created_at = 5 [(tagger.tags) = "json:\"user_created_at,omitempty\"" ];
google.protobuf.Timestamp classified_at = 6 [(tagger.tags) = "json:\"classified_at,omitempty\"" ];
google.protobuf.Timestamp comment_created_at = 4;
google.protobuf.Timestamp user_created_at = 5;
google.protobuf.Timestamp classified_at = 6;
string link = 7;
string lang = 8;
double threshold = 9;
string version = 10;
}
}
3 changes: 1 addition & 2 deletions proto/cvcio/classification/predictions.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
syntax = "proto3";

package common;
option go_package = "github.com/cvcio/proto/internal/common";
package classification;

message Prediction {
string label = 1;
Expand Down
Loading

0 comments on commit 1d7df90

Please sign in to comment.