Skip to content
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

chore: Develop #6

Merged
merged 26 commits into from
Apr 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
0fab7b6
count points
lucbellicaud Mar 31, 2023
759ae4d
alert symbol instead of abbrevation
lucbellicaud Apr 3, 2023
2ba39b8
Squashed commit of the following:
lucbellicaud Apr 6, 2023
ca9b168
DDS lead
lucbellicaud Apr 12, 2023
54ff53b
feat: Add otel into development docker-compose
zdraganov Apr 13, 2023
10399da
Fix small cards dds 2
lucbellicaud Apr 13, 2023
4b6006d
Merge branch 'develop' of https://github.com/Seven-of-Di/ben into dev…
lucbellicaud Apr 13, 2023
9a1e5f0
test lead
lucbellicaud Apr 13, 2023
2660d36
Merge branch 'staging' into develop
lucbellicaud Apr 13, 2023
80bd6eb
feat: Intrument Ben with Tracing for PlayCard flow
zdraganov Apr 13, 2023
481b0db
feat: Add integrnal loadtest package for simplify running loadtests
zdraganov Apr 14, 2023
6c2fc07
feat: Update the README.md for the loadtest package
zdraganov Apr 14, 2023
421ac69
fixed big bug : not taking pb into account
lucbellicaud Apr 17, 2023
103ae6b
Merge branch 'develop' of https://github.com/Seven-of-Di/ben into dev…
lucbellicaud Apr 17, 2023
421e035
Update transform_play_card.py
lucbellicaud Apr 17, 2023
760dd47
feat: Reconstructure the code and add more samples
zdraganov Apr 18, 2023
52269b4
optimize sample ordering
lucbellicaud Apr 18, 2023
97aa583
Clean up variables names + time tricking
lucbellicaud Apr 18, 2023
1f007e0
feat: Change to use hypercorn
zdraganov Apr 18, 2023
f8c6873
Add some tracers
lucbellicaud Apr 18, 2023
0814048
Merge branch 'develop' of https://github.com/Seven-of-Di/ben into dev…
lucbellicaud Apr 18, 2023
3297b54
feat: Make the number of leading samples configurable
zdraganov Apr 19, 2023
d1073b6
Less redoubles + fix tracer of dds
lucbellicaud Apr 19, 2023
e111c6e
Merge branch 'develop' of https://github.com/Seven-of-Di/ben into dev…
lucbellicaud Apr 19, 2023
4ce4bbe
back to 100 samples
lucbellicaud Apr 19, 2023
4cbd2cb
feat: Include game information in the traces attributes
zdraganov Apr 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Intrument Ben with Tracing for PlayCard flow
  • Loading branch information
zdraganov committed Apr 13, 2023
commit 80bd6eb0c4e586bb0ad3c8d64f9e056deb1634aa
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
command: python api.py
# command: python create_alerts_database.py
ports:
- 8081:8081
- 5001:5001
volumes:
- ./src:/app/src
- ./build/alerts_db:/var/lib/alerts_db
Expand All @@ -23,7 +23,8 @@ services:
- PORT=5001
- DEBUG=true
- USE_RELOADER=true
- OTEL_EXPORTER_OTLP_SPAN_ENDPOINT=otel:4317
- OTEL_EXPORTER_OTLP_TRACES_INSECURE=True
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=otel:4317
- OTEL_SERVICE_NAME=robot
networks:
- ben
Expand Down
38 changes: 34 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,38 @@
tensorflow==2.11.0
aiofiles==23.1.0
asgiref==3.6.0
blinker==1.6.2
certifi==2022.12.7
click==8.1.3
Deprecated==1.2.13
h11==0.14.0
h2==4.1.0
hpack==4.0.0
hypercorn==0.14.3
hyperframe==6.0.1
importlib-metadata==6.0.1
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.2
opentelemetry-api==1.17.0
opentelemetry-sdk==1.17.0
opentelemetry-exporter-otlp-proto-grpc==1.17.0
opentelemetry-instrumentation==0.38b0
opentelemetry-instrumentation-asgi==0.38b0
opentelemetry-semantic-conventions==0.38b0
opentelemetry-util-http==0.38b0
pickle5==0.0.11
priority==2.0.0
protobuf==3.19.0
psutil==5.9.4
quart==0.18.3
hypercorn==0.14.3
sentry-sdk==1.16.0
psutil==5.9.4
sqlitedict==2.1.0
pickle5==0.0.11
tensorflow==2.11.0
toml==0.10.2
typing_extensions==4.5.0
urllib3==1.26.15
Werkzeug==2.2.3
wrapt==1.15.0
wsproto==1.2.0
zipp==3.15.0

4 changes: 4 additions & 0 deletions resp.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"card": "S4",
"claim_the_rest": false
}
6 changes: 4 additions & 2 deletions src/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from copy import deepcopy
from typing import Dict, List
from quart import Quart, request
from opentelemetry.instrumentation.asgi import OpenTelemetryMiddleware

from nn.models import MODELS
from game import AsyncBotBid, AsyncBotLead
Expand All @@ -10,8 +11,8 @@

import os
import sentry_sdk
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware

from sentry_sdk.integrations.asgi import SentryAsgiMiddleware

from transform_play_card import get_ben_card_play_answer
from human_carding import lead_real_card
Expand All @@ -30,6 +31,7 @@

app = Quart(__name__)
app.asgi_app = SentryAsgiMiddleware(app.asgi_app)._run_asgi3
app.asgi_app = OpenTelemetryMiddleware(app.asgi_app)

health_checker = HealthChecker(app.logger)
health_checker.start()
Expand Down Expand Up @@ -116,7 +118,6 @@ def __init__(self, play_full_board_request) -> None:
}
'''


@app.post('/play_card')
async def play_card():
data = await request.get_json()
Expand All @@ -135,6 +136,7 @@ async def play_card():
req.tricks,
MODELS
)

"""
dict_result = {
"card": "H4",
Expand Down
2 changes: 2 additions & 0 deletions src/claim_dds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations
from copy import deepcopy
import random
from tracing import tracer
from typing import Dict, List, Set, Tuple
from utils import Diag, Direction, Card_, BiddingSuit, Suit, Rank, PlayerHand, TOTAL_DECK
from PlayRecord import PlayRecord, Trick
Expand Down Expand Up @@ -179,6 +180,7 @@ def check_claim(diag: Diag, claim: int, claim_direction: Direction, trump: Biddi
return dds_check(diags[:5], trump, trick_leader, current_trick, claim, claim_direction, declarer) and dds_check(diags[5:], trump, trick_leader, current_trick, claim, claim_direction, declarer)


@tracer.start_as_current_span("check_claim_from_api")
async def check_claim_from_api(claiming_hand_str: str, dummy_hand_str: str, claiming_direction_str: str, declarer_str: str, contract_str: str, tricks_as_str: List[List[str]], absolute_claim: int, n_samples=200) -> bool:
claiming_direction = Direction.from_str(claiming_direction_str)
declarer = Direction.from_str(declarer_str)
Expand Down
2 changes: 2 additions & 0 deletions src/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from bidding import bidding
from utils import convert_to_probability
from util import get_all_hidden_cards, view_samples
from tracing import tracer
from nn.bidder import Bidder


Expand Down Expand Up @@ -413,6 +414,7 @@ def player_to_nesw_i(player_i, contract):
return (decl_i + player_i + 1) % 4


@tracer.start_as_current_span("init_rollout_states")
def init_rollout_states(trick_i, player_i, card_players, player_cards_played, shown_out_suits, current_trick, n_samples, auction, hand, vuln, models):
leader_i = (player_i - len(current_trick)) % 4

Expand Down
16 changes: 16 additions & 0 deletions src/tracing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from opentelemetry import trace
from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter

from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
BatchSpanProcessor,
)

provider = TracerProvider()
processor = BatchSpanProcessor(OTLPSpanExporter())

provider.add_span_processor(processor)

trace.set_tracer_provider(provider)

tracer = trace.get_tracer_provider().get_tracer(__name__)
2 changes: 2 additions & 0 deletions src/transform_play_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from copy import deepcopy
import random
from typing import Dict, List
from tracing import tracer
import numpy as np
from datetime import datetime

Expand Down Expand Up @@ -29,6 +30,7 @@ def get_play_status(hand: PlayerHand, current_trick: List[Card_]):
return "Follow"


@tracer.start_as_current_span("get_ben_card_play_answer")
async def get_ben_card_play_answer(hand_str, dummy_hand_str, dealer_str, vuls, auction, contract, declarer_str, next_player_str, tricks_str, MODELS) -> Dict:
n_samples = 100
claim_res = False
Expand Down