Skip to content

Commit

Permalink
Update colab-specific install
Browse files Browse the repository at this point in the history
- only pip install if kernel is colab kernel
- pip install in one command
- rename examples/requirements.txt to requirements.in

PiperOrigin-RevId: 705300112
Change-Id: I965c6386100e88c93d070a8956014c210c635a14
  • Loading branch information
jagapiou authored and copybara-github committed Dec 12, 2024
1 parent 028907c commit c32219b
Show file tree
Hide file tree
Showing 18 changed files with 166 additions and 316 deletions.
22 changes: 10 additions & 12 deletions examples/brainstorm/brainstorm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,16 @@
},
"outputs": [],
"source": [
"%pip install --ignore-requires-python git+https://github.com/google-deepmind/concordia.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "-fmBHd6Wdc6H"
},
"outputs": [],
"source": [
"%pip install -r https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.txt"
"# @title Colab-specific setup (use a CodeSpace to avoid the need for this).\n",
"try:\n",
" %env COLAB_RELEASE_TAG\n",
"except:\n",
" pass # Not running in colab.\n",
"else:\n",
" %pip install --ignore-requires-python \\\n",
" --requirement 'https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.in' \\\n",
" 'git+https://github.com/google-deepmind/concordia.git#egg=gdm-concordia'\n",
" %pip list"
]
},
{
Expand Down
22 changes: 10 additions & 12 deletions examples/cyberball/cyberball.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,16 @@
},
"outputs": [],
"source": [
"%pip install --ignore-requires-python git+https://github.com/google-deepmind/concordia.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "reWNIvR24HT6"
},
"outputs": [],
"source": [
"%pip install -r https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.txt"
"# @title Colab-specific setup (use a CodeSpace to avoid the need for this).\n",
"try:\n",
" %env COLAB_RELEASE_TAG\n",
"except:\n",
" pass # Not running in colab.\n",
"else:\n",
" %pip install --ignore-requires-python \\\n",
" --requirement 'https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.in' \\\n",
" 'git+https://github.com/google-deepmind/concordia.git#egg=gdm-concordia'\n",
" %pip list"
]
},
{
Expand Down
22 changes: 10 additions & 12 deletions examples/example_with_scenes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@
},
"outputs": [],
"source": [
"%pip install --ignore-requires-python git+https://github.com/google-deepmind/concordia.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "B_JQ_dJDpBVC"
},
"outputs": [],
"source": [
"%pip install -r https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.txt"
"# @title Colab-specific setup (use a CodeSpace to avoid the need for this).\n",
"try:\n",
" %env COLAB_RELEASE_TAG\n",
"except:\n",
" pass # Not running in colab.\n",
"else:\n",
" %pip install --ignore-requires-python \\\n",
" --requirement 'https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.in' \\\n",
" 'git+https://github.com/google-deepmind/concordia.git#egg=gdm-concordia'\n",
" %pip list"
]
},
{
Expand Down
22 changes: 10 additions & 12 deletions examples/magic_beans_for_sale.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@
},
"outputs": [],
"source": [
"%pip install --ignore-requires-python git+https://github.com/google-deepmind/concordia.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "8wj9r4GR0RF5"
},
"outputs": [],
"source": [
"%pip install -r https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.txt"
"# @title Colab-specific setup (use a CodeSpace to avoid the need for this).\n",
"try:\n",
" %env COLAB_RELEASE_TAG\n",
"except:\n",
" pass # Not running in colab.\n",
"else:\n",
" %pip install --ignore-requires-python \\\n",
" --requirement 'https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.in' \\\n",
" 'git+https://github.com/google-deepmind/concordia.git#egg=gdm-concordia'\n",
" %pip list"
]
},
{
Expand Down
41 changes: 9 additions & 32 deletions examples/modular/notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,40 +40,17 @@
"outputs": [],
"source": [
"# @title Colab-specific setup (use a CodeSpace to avoid the need for this).\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"if os.getenv(\"COLAB_RELEASE_TAG\"):\n",
" project_root = '/content/concordia'\n",
"\n",
" # Download the source code.\n",
" if not os.path.exists(project_root):\n",
" !git clone https://github.com/google-deepmind/concordia.git\n",
"\n",
" # Install concordia and dependencies.\n",
" %pip install --ignore-requires-python -e /content/concordia\n",
" %pip install -r /content/concordia/examples/requirements.txt\n"
"try:\n",
" %env COLAB_RELEASE_TAG\n",
"except:\n",
" pass # Not running in colab.\n",
"else:\n",
" %pip install --ignore-requires-python \\\n",
" --requirement 'https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.in' \\\n",
" 'git+https://github.com/google-deepmind/concordia.git#egg=gdm-concordia'\n",
" %pip list"
]
},
{
"metadata": {
"id": "HRk1RJZJHkJH"
},
"cell_type": "code",
"source": [
"import sys\n",
"\n",
"if os.getenv(\"COLAB_RELEASE_TAG\"):\n",
" project_root = '/content/concordia'\n",
"\n",
" # Add root to python path.\n",
" if project_root not in sys.path:\n",
" sys.path.append(project_root)"
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
27 changes: 9 additions & 18 deletions examples/phone/calendar.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,15 @@
"outputs": [],
"source": [
"# @title Colab-specific setup (use a CodeSpace to avoid the need for this).\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"if os.getenv(\"COLAB_RELEASE_TAG\"):\n",
" project_root = '/content/concordia'\n",
"\n",
" # Download the source code.\n",
" if not os.path.exists(project_root):\n",
" !git clone https://github.com/google-deepmind/concordia.git\n",
"\n",
" # Install concordia and dependencies.\n",
" %pip install --ignore-requires-python -e /content/concordia\n",
" %pip install -r /content/concordia/examples/requirements.txt\n",
"\n",
" # Add root to python path.\n",
" if project_root not in sys.path:\n",
" sys.path.append(project_root)"
"try:\n",
" %env COLAB_RELEASE_TAG\n",
"except:\n",
" pass # Not running in colab.\n",
"else:\n",
" %pip install --ignore-requires-python \\\n",
" --requirement 'https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.in' \\\n",
" 'git+https://github.com/google-deepmind/concordia.git#egg=gdm-concordia'\n",
" %pip list"
]
},
{
Expand Down
22 changes: 10 additions & 12 deletions examples/pytorch_gemma_local.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@
},
"outputs": [],
"source": [
"%pip install --ignore-requires-python git+https://github.com/google-deepmind/concordia.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "WvRB61fWVRpW"
},
"outputs": [],
"source": [
"%pip install -r https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.txt"
"# @title Colab-specific setup (use a CodeSpace to avoid the need for this).\n",
"try:\n",
" %env COLAB_RELEASE_TAG\n",
"except:\n",
" pass # Not running in colab.\n",
"else:\n",
" %pip install --ignore-requires-python \\\n",
" --requirement 'https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.in' \\\n",
" 'git+https://github.com/google-deepmind/concordia.git#egg=gdm-concordia'\n",
" %pip list"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions examples/requirements.txt → examples/requirements.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Requirements for the Concordia examples.
absl-py
docstring-parser
gdm-concordia
Expand Down
22 changes: 10 additions & 12 deletions examples/smoking_cessation_in_an_alchemical_world.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,16 @@
},
"outputs": [],
"source": [
"%pip install --ignore-requires-python git+https://github.com/google-deepmind/concordia.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "B_JQ_dJDpBVC"
},
"outputs": [],
"source": [
"%pip install -r https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.txt"
"# @title Colab-specific setup (use a CodeSpace to avoid the need for this).\n",
"try:\n",
" %env COLAB_RELEASE_TAG\n",
"except:\n",
" pass # Not running in colab.\n",
"else:\n",
" %pip install --ignore-requires-python \\\n",
" --requirement 'https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.in' \\\n",
" 'git+https://github.com/google-deepmind/concordia.git#egg=gdm-concordia'\n",
" %pip list"
]
},
{
Expand Down
25 changes: 11 additions & 14 deletions examples/three_key_questions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,16 @@
},
"outputs": [],
"source": [
"%pip install --ignore-requires-python git+https://github.com/google-deepmind/concordia.git"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "reWNIvR24HT6"
},
"outputs": [],
"source": [
"%pip install -r https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.txt"
"# @title Colab-specific setup (use a CodeSpace to avoid the need for this).\n",
"try:\n",
" %env COLAB_RELEASE_TAG\n",
"except:\n",
" pass # Not running in colab.\n",
"else:\n",
" %pip install --ignore-requires-python \\\n",
" --requirement 'https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.in' \\\n",
" 'git+https://github.com/google-deepmind/concordia.git#egg=gdm-concordia'\n",
" %pip list"
]
},
{
Expand Down Expand Up @@ -452,8 +450,7 @@
" # All players get the same `measurements` object.\n",
" [measurements] * NUM_PLAYERS):\n",
" players.append(agent)\n",
" memories[agent.name] = mem\n",
"\n"
" memories[agent.name] = mem\n"
]
},
{
Expand Down
42 changes: 9 additions & 33 deletions examples/tutorials/agent_basic_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,17 @@
"outputs": [],
"source": [
"# @title Colab-specific setup (use a CodeSpace to avoid the need for this).\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"if os.getenv(\"COLAB_RELEASE_TAG\"):\n",
" project_root = '/content/concordia'\n",
"\n",
" # Download the source code.\n",
" if not os.path.exists(project_root):\n",
" !git clone https://github.com/google-deepmind/concordia.git\n",
"\n",
" # Install concordia and dependencies.\n",
" %pip install --ignore-requires-python -e /content/concordia\n",
" %pip install -r /content/concordia/examples/requirements.txt\n"
"try:\n",
" %env COLAB_RELEASE_TAG\n",
"except:\n",
" pass # Not running in colab.\n",
"else:\n",
" %pip install --ignore-requires-python \\\n",
" --requirement 'https://raw.githubusercontent.com/google-deepmind/concordia/main/examples/requirements.in' \\\n",
" 'git+https://github.com/google-deepmind/concordia.git#egg=gdm-concordia'\n",
" %pip list"
]
},
{
"metadata": {
"id": "kKdI8JqvJgPN"
},
"cell_type": "code",
"source": [
"import sys\n",
"import os\n",
"\n",
"if os.getenv(\"COLAB_RELEASE_TAG\"):\n",
" project_root = '/content/concordia'\n",
"\n",
" # Add root to python path.\n",
" if project_root not in sys.path:\n",
" sys.path.append(project_root)"
],
"outputs": [],
"execution_count": null
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
Loading

0 comments on commit c32219b

Please sign in to comment.