Skip to content

Commit

Permalink
support and run ruff formatter (#148)
Browse files Browse the repository at this point in the history
* fix ruff format

* fix ruff format

* fix ruff format

* change pyproject

* fix ruff format

* fix codespell error
  • Loading branch information
lwaekfjlk authored May 30, 2024
1 parent 787bb88 commit c5b8627
Show file tree
Hide file tree
Showing 37 changed files with 966 additions and 751 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ repos:
- id: ruff
types_or: [python, pyi, jupyter]
args: [--fix]
- id: ruff-format
types_or: [python, pyi, jupyter]

- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1 # Use the latest isort version
Expand Down
16 changes: 16 additions & 0 deletions data/dbs/test_agent_profile_db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"d544f290-6748-46b5-a82e-fd8f40c1e4cc": {
"pk": "d544f290-6748-46b5-a82e-fd8f40c1e4cc",
"name": "Jane Smith",
"bio": "Expert in NLP",
"collaborators": [],
"institute": "NLP Lab"
},
"9c581b74-86f6-4577-b400-9221df4c3917": {
"pk": "9c581b74-86f6-4577-b400-9221df4c3917",
"name": "Alice Johnson",
"bio": "Data Scientist",
"collaborators": [],
"institute": "Data Lab"
}
}
43 changes: 43 additions & 0 deletions data/dbs/test_env_logs_db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"PaperProfile": [],
"AgentPaperReviewLog": [
{
"pk": "654935ea-be94-4898-80a4-bb5c7c12f286",
"timestep": 0,
"paper_pk": "paper2",
"agent_pk": "agent2",
"review_score": 4,
"review_content": "Interesting paper"
}
],
"AgentPaperRebuttalLog": [
{
"pk": "5387eadb-6a18-44e1-b7a3-55c49c808efd",
"timestep": 0,
"paper_pk": "paper1",
"agent_pk": "agent1",
"rebuttal_content": "I disagree with the review"
}
],
"AgentPaperMetaReviewLog": [
{
"pk": "f3bffbbc-c67c-40a5-82f1-200989b2bea9",
"timestep": 0,
"paper_pk": "paper1",
"agent_pk": "agent1",
"decision": true,
"meta_review": "Accept"
}
],
"AgentAgentDiscussionLog": [
{
"pk": "67a25e19-2182-4671-9005-a3f95dd3f7c0",
"timestep": 0,
"agent_from_pk": "agent1",
"agent_from_name": "Rex Ying",
"agent_to_pk": "agent2",
"agent_to_name": "John Doe",
"message": "Let's discuss this paper"
}
]
}
46 changes: 46 additions & 0 deletions data/dbs/test_paper_profile_db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"43653097-1230-48e5-ba17-6f616bc93380": {
"pk": "43653097-1230-48e5-ba17-6f616bc93380",
"title": "Updated Sample Paper 1",
"abstract": "This is the abstract for paper 1",
"authors": [
"Author A",
"Author B"
],
"url": "http://example.com/paper1",
"timestamp": 1617181723,
"section_contents": null,
"table_captions": null,
"figure_captions": null,
"bibliography": null,
"keywords": [
"AI",
"ML"
],
"domain": "Computer Science",
"references": null,
"citation_count": 15,
"award": null
},
"37e9c697-bd7b-40da-975f-579eddc9508e": {
"pk": "37e9c697-bd7b-40da-975f-579eddc9508e",
"title": "Sample Paper 3",
"abstract": "This is the abstract for paper 3",
"authors": [
"Author D"
],
"url": "http://example.com/paper3",
"timestamp": 1617181789,
"section_contents": null,
"table_captions": null,
"figure_captions": null,
"bibliography": null,
"keywords": [
"Blockchain"
],
"domain": "Computer Science",
"references": null,
"citation_count": 2,
"award": null
}
}
13 changes: 13 additions & 0 deletions data/dbs/test_research_progress_db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"ResearchIdea": [
{
"pk": "585e0e17-ae53-44a1-a682-e4ee2883655c",
"content": "Blockchain research proposal"
},
{
"pk": "baf40f3b-f14b-48a0-bc1c-d84eaefa9e58",
"content": "Updated idea content"
}
],
"ResearchPaper": []
}
35 changes: 19 additions & 16 deletions examples/minimal_demo.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
from beartype.typing import Dict, List

from research_town.dbs import (
AgentProfile,
AgentProfileDB,
EnvLogDB,
PaperProfileDB,
)
from research_town.dbs import AgentProfile, AgentProfileDB, EnvLogDB, PaperProfileDB
from research_town.envs import (
PaperRebuttalMultiAgentEnv,
PaperSubmissionMultiAgentEnvironment,
)


def run_sync_experiment(agent_list: List[str], role_list: List[str], task: Dict[str, str]) -> None:
def run_sync_experiment(
agent_list: List[str], role_list: List[str], task: Dict[str, str]
) -> None:
# Create Environment and Agents
agent_profiles = [AgentProfile(
name=agent, bio="A researcher in machine learning.") for agent in agent_list]
agent_profiles = [
AgentProfile(name=agent, bio='A researcher in machine learning.')
for agent in agent_list
]
agent_db = AgentProfileDB()
paper_db = PaperProfileDB()
env_db = EnvLogDB()
paper_submission_env = PaperSubmissionMultiAgentEnvironment(
agent_profiles=agent_profiles, task=task,
agent_profiles=agent_profiles,
task=task,
agent_db=agent_db,
paper_db=paper_db,
env_db=env_db)
env_db=env_db,
)
paper_rebuttal_env = PaperRebuttalMultiAgentEnv(
agent_profiles=agent_profiles,
agent_db=agent_db,
paper_db=paper_db,
env_db=env_db)
env_db=env_db,
)

# Paper Submission
submission_done = False
Expand All @@ -51,10 +53,11 @@ def run_sync_experiment(agent_list: List[str], role_list: List[str], task: Dict[

def main() -> None:
run_sync_experiment(
agent_list=["Jiaxuan You", "Jure Leskovec"],
role_list=["author", "reviewer"],
task={})
agent_list=['Jiaxuan You', 'Jure Leskovec'],
role_list=['author', 'reviewer'],
task={},
)


if __name__ == "__main__":
if __name__ == '__main__':
main()
17 changes: 16 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,22 @@ skip_gitignore = true
multi_line_output = 3
include_trailing_comma = true
force_grid_wrap = 0
line_length = 70
line_length = 88

[tool.black]
line-length = 88
target-version = ['py37', 'py38', 'py39', 'py310']

[tool.ruff]
line-length = 88
fix = true
target-version = "py310"

[tool.ruff.format]
quote-style = "single"
indent-style = "space"
docstring-code-format = true
docstring-code-line-length = 88

[tool.mypy-arxiv]
ignore_missing_imports = true
Expand Down
Loading

0 comments on commit c5b8627

Please sign in to comment.