Skip to content

Commit

Permalink
Upgrade python3.12 and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
asaf-kali committed Nov 11, 2024
1 parent 1c1e4d2 commit 1b115d2
Show file tree
Hide file tree
Showing 9 changed files with 1,324 additions and 1,290 deletions.
4 changes: 2 additions & 2 deletions .github/actions/lint-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ description: "A reusable action to install linting tools"
runs:
using: "composite"
steps:
- name: Set up python 3.10
- name: Set up python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
shell: bash
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up python 3.10
- name: Set up python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.12"
- name: Install dependencies
run: |
make install-ci
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/video.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Set up python 3.10
- name: Set up python 3.12
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.12"
- name: Install video dependencies
run: |
make install-ci
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ upgrade-pip:
pip install --upgrade pip

install-ci: upgrade-pip
pip install poetry==1.5.1
pip install poetry==1.8.3
poetry config virtualenvs.create false

install-test:
Expand All @@ -41,7 +41,7 @@ lock:
poetry lock --no-update

lock-check:
poetry lock --check
poetry check --lock

# Test

Expand Down Expand Up @@ -111,12 +111,12 @@ gource-all:
# Lint

format:
ruff . --fix
ruff check --fix
black .
isort .

check-ruff:
ruff .
ruff check

check-black:
black --check .
Expand Down
56 changes: 28 additions & 28 deletions playground/asaf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import logging\n",
Expand All @@ -16,14 +19,14 @@
"configure_logging()\n",
"\n",
"log = logging.getLogger(__name__)"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from solvers.models import ModelIdentifier, HEBREW_SUFFIX_ADAPTER, load_model_async, DEFAULT_MODEL_ADAPTER\n",
Expand All @@ -49,25 +52,25 @@
"red_guesser = NaiveGuesser(\"Eve\", model_identifier=model_id, model_adapter=adapter)\n",
"\n",
"game_runner = GameRunner(blue_hinter, red_hinter, blue_guesser, red_guesser)"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"r = game_runner.run_game()"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
Expand All @@ -81,14 +84,14 @@
"source": [
"# game_runner.run_game(language=\"english\", board=english_board)\n",
"result = game_runner.run_game(language=\"hebrew\", board=HEBREW_BOARD_1)"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from codenames.online import NamecodingGameRunner, NamecodingLanguage\n",
Expand All @@ -107,14 +110,14 @@
" log.info(f\"Winner: {online_runner.winner}\")\n",
" online_runner.close()\n",
"log.info(\"Done\")"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -142,22 +145,19 @@
" # log.info(\"Checking %s\", word)\n",
" try:\n",
" x = model[adapter.to_model_format(word)]\n",
" except Exception as e:\n",
" except Exception:\n",
" errors.append(word)\n",
"print(\"Done with %d errors\" % len(errors))"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
}
},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
48 changes: 24 additions & 24 deletions playground/gpt.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Load env vars\n",
Expand All @@ -12,10 +15,7 @@
" for line in f:\n",
" var = line.strip().split(\"=\")\n",
" os.environ[var[0]] = var[1]"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
Expand All @@ -33,10 +33,13 @@
{
"cell_type": "code",
"execution_count": 78,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"# Consts\n",
"full_instructions = f\"\"\"You are a chatbot playing the Codenames board game. Players are split into two teams: blue and red. One player in each team is selected as the team's spymaster (the Hinter); the rest become field operatives (Guessers).\n",
"full_instructions = \"\"\"You are a chatbot playing the Codenames board game. Players are split into two teams: blue and red. One player in each team is selected as the team's spymaster (the Hinter); the rest become field operatives (Guessers).\n",
"Twenty-five codename cards, each bearing a word, are laid out in a 5×5 grid in random order. A number of these words represent blue agents, a number represent red agents, one represents an assassin, and the rest represent innocent bystanders. The teams' spymasters are given a randomly-dealt key card showing a 5×5 grid of 25 squares of various colors, each corresponding to one of the codename cards on the table.\n",
"On each turn, the appropriate spymaster gives a verbal hint about the words on the respective cards. Each hint may only consist of one single word and a number. The clue has to be related to as many of the words on the team's own agents' cards as possible, but not to any others – lest the words accidentally lead them to choose a card representing an innocent bystander, an opposing agent, or the assassin. The clue word can be chosen freely, as long as it is not (and does not contain, nor is contained in) any of the words on the codename cards still visible at the time. Codename cards are covered as guesses, correct or otherwise, are made.\n",
"The number in the hint tells the field operatives how many words in the grid are related to the clue word. It also determines the maximum number of guesses the field operatives may make on that turn, which is the stated number plus one. The field operatives of a team are required to make at least one guess per turn, risking a wrong guess and its consequences. If their first guess is right, the field operatives may continue to make guesses until they reach the guess limit or make a wrong guess, or they can instead choose to end their turn voluntarily.\n",
Expand All @@ -47,14 +50,14 @@
"The game ends when all agents belonging to one team are identified, winning the game for that team. However, revealing the assassin immediately ends the game with a loss for the team who identified him. If an opposing agent or innocent bystander is identified, the turn ends, and the other team gains a small advantage before starting their turn. The spymaster's hints cannot contain any of the words on the codename cards still visible, and the game continues until one team wins or the assassin is revealed.\"\"\"\n",
"turn_command = \"\"\"Please provide a valid hint, along with the words your hint is referring to, in JSON format: `{\"word\": <hint_word>, \"referred_cards\": <list_of_cards>}`.\n",
"Try to refer at least 2 cards, and only refer 4 cards if you think the hint represent these words well.\"\"\""
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": 90,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from codenames.game import Board, CardColor, GivenHint, TeamColor\n",
Expand Down Expand Up @@ -97,14 +100,14 @@
"def build_allowed_cards_repr(board: Board, team_color: TeamColor) -> str:\n",
" words = [card.word for card in board.unrevealed_cards_for_color(team_color.as_card_color)]\n",
" return f\"These are the words you are looking for hints to: {', '.join(words)}.\""
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": 93,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"_board = ENGLISH_BOARD_1\n",
Expand All @@ -129,14 +132,14 @@
" # TODO: Add all the hints and guesses given so far\n",
" {\"role\": \"user\", \"content\": command_prompt},\n",
"]"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
"execution_count": 94,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -169,10 +172,7 @@
"source": [
"completion = openai.ChatCompletion.create(model=\"gpt-3.5-turbo\", messages=messages)\n",
"print(completion)"
],
"metadata": {
"collapsed": false
}
]
},
{
"cell_type": "code",
Expand Down Expand Up @@ -204,11 +204,11 @@
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
}
},
"outputs": [],
"source": []
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 1b115d2

Please sign in to comment.