From e692ec92178d4b18e4336fd222132d283e03ef40 Mon Sep 17 00:00:00 2001 From: Federico Berto Date: Tue, 14 Jan 2025 13:49:21 +0900 Subject: [PATCH 1/5] [Chore] ignore uv.lock --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 49ee5261..297a3290 100644 --- a/.gitignore +++ b/.gitignore @@ -167,6 +167,9 @@ wandb/ # poetry poetry.lock +# uv +uv.lock + # idea .idea From 6003283b7cef7835e2f3d498d8a928889326a849 Mon Sep 17 00:00:00 2001 From: Federico Berto Date: Tue, 14 Jan 2025 13:49:56 +0900 Subject: [PATCH 2/5] [License] 2025 --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index 799cc5ba..6c3a644f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2024 AI4CO +Copyright (c) 2025 AI4CO Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 5d205098a30d8200a16ed93de8f28b52cdec2915 Mon Sep 17 00:00:00 2001 From: Federico Berto Date: Tue, 14 Jan 2025 14:20:06 +0900 Subject: [PATCH 3/5] [Feat] update build system and follow PEP 621 standards --- pyproject.toml | 177 +++++++++++++++++++++++-------------------------- 1 file changed, 84 insertions(+), 93 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 992c3df7..fc3125b4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,47 +1,48 @@ -[tool.poetry] +[project] name = "rl4co" -version = "0.5.1" +version = "0.5.2dev0" description = "RL4CO: an Extensive Reinforcement Learning for Combinatorial Optimization Benchmark" authors = [ - "Federico Berto ", - "Chuanbo Hua ", - "Junyoung Park ", - "Laurin Luttmann ", - "Yining Ma", - "Fanchen Bu", - "Jiarui Wang", - "Haoran Ye", - "Minsu Kim", - "Sanghyeok Choi", - "Zepeda Gast", - "Andre Hottung", - "Jianan Zhou", - "Jieyi Bi", - "Yu Hu", - "Fei Liu", - "Hyeonah Kim", - "Jiwoo Son", - "Haeyeon Kim", - "Davide Angioni", - "Wouter Kool", - "Zhiguang Cao", - "Jie Zhang", - "Kijung Shin", - "Cathy Wu", - "Sungsoo Ahn", - "Guojie Song", - "Changhyun Kwon", - "Lin Xie", - "Jinkyoo Park", - "AI4CO", + { name = "Federico Berto", email = "berto.federico2@gmail.com" }, + { name = "Chuanbo Hua", email = "cbhua@kaist.ac.kr" }, + { name = "Junyoung Park", email = "junyoungpark.ml@gmail.com" }, + { name = "Laurin Luttmann", email = "laurin.luttmann@gmail.com" }, + { name = "Yining Ma" }, + { name = "Fanchen Bu" }, + { name = "Jiarui Wang" }, + { name = "Haoran Ye" }, + { name = "Minsu Kim" }, + { name = "Sanghyeok Choi" }, + { name = "Zepeda Gast" }, + { name = "Andre Hottung" }, + { name = "Jianan Zhou" }, + { name = "Jieyi Bi" }, + { name = "Yu Hu" }, + { name = "Fei Liu" }, + { name = "Hyeonah Kim" }, + { name = "Jiwoo Son" }, + { name = "Haeyeon Kim" }, + { name = "Davide Angioni" }, + { name = "Wouter Kool" }, + { name = "Zhiguang Cao" }, + { name = "Jie Zhang" }, + { name = "Kijung Shin" }, + { name = "Cathy Wu" }, + { name = "Sungsoo Ahn" }, + { name = "Guojie Song" }, + { name = "Changhyun Kwon" }, + { name = "Lin Xie" }, + { name = "Jinkyoo Park" }, + { name = "AI4CO" }, ] +requires-python = ">=3.9" readme = "README.md" license = "MIT" -homepage = "https://rl4.co" -repository = "https://github.com/ai4co/rl4co" -documentation = "https://rl4co.readthedocs.io" -keywords = ["reinforcement learning", "combinatorial optimization", "benchmark"] -packages = [{ include = "rl4co" }] +keywords = [ + "reinforcement learning", + "combinatorial optimization", + "benchmark", +] classifiers = [ "Programming Language :: Python", "Programming Language :: Python :: 3", @@ -54,59 +55,37 @@ classifiers = [ "Intended Audience :: Developers", "Intended Audience :: Science/Research", "Operating System :: OS Independent", - "Topic :: Scientific/Engineering :: Artificial Intelligence" + "Topic :: Scientific/Engineering :: Artificial Intelligence", +] +dependencies = [ + "einops", + "hydra-core", + "hydra-colorlog", + "lightning>=2.1.0", + "matplotlib", + "omegaconf", + "pyrootutils", + "rich", + "robust-downloader", + "scipy", + "tensordict>=0.6.0", + "torchrl>=0.6.0", + "wandb", ] -[tool.poetry.urls] -"Tracker" = "https://github.com/ai4co/rl4co/issues" - -[tool.poetry.dependencies] -# Required dependencies -python = ">=3.9" -einops = "*" -hydra-core = "*" -hydra-colorlog = "*" -lightning = ">=2.1.0" -matplotlib = "*" -omegaconf = "*" -pyrootutils = "*" -rich = "*" -robust-downloader = "*" -scipy = "*" -tensordict = ">=0.6.0" -torchrl = ">=0.6.0" -wandb = "*" -# Dev dependencies -black = { version = "*", optional = true } -pre-commit = { version = ">=3.3.3", optional = true } -ruff = { version = "*", optional = true } -pytest = { version = "*", optional = true } -pytest-cov = { version = "*", optional = true } -# Graph -torch_geometric = { version = "*", optional = true } -# Routing -numba = { version = ">=0.58.1", optional = true } -pyvrp = { version = ">=0.9.0", optional = true, python = "<4.0" } -# Docs -mkdocs = { version = "*", optional = true } -mkdocs-material = { version = "*", optional = true } -mkdocstrings-python = { version = "*", optional = true } -mike = { version = "*", optional = true } -mkdocs-jupyter = { version = "*", optional = true } -mkdocs-redirects = { version = "*", optional = true } -mkdocs-autolinks-plugin = { version = "*", optional = true } -griffe-typingdoc = { version = "*", optional = true } -griffe-inherited-docstrings = { version = "*", optional = true } -griffe = { version = "*", optional = true } -mkdocs-same-dir = { version = "*", optional = true } -mdx-breakless-lists = { version = "*", optional = true } -mdx-truly-sane-lists = { version = "*", optional = true } -markdown-gfm-admonition = { version = "*", optional = true } - -[tool.poetry.extras] -dev = ["black", "pre-commit", "ruff", "pytest", "pytest-cov"] +[project.optional-dependencies] +dev = [ + "black", + "pre-commit>=3.3.3", + "ruff", + "pytest", + "pytest-cov", +] graph = ["torch_geometric"] -routing = ["numba", "pyvrp"] +routing = [ + "numba>=0.58.1", + "pyvrp>=0.9.0 ; python_version < '4.0'", +] docs = [ "mkdocs", "mkdocs-material", @@ -118,13 +97,29 @@ docs = [ "griffe-typingdoc", "griffe-inherited-docstrings", "griffe", - "black", # for formatting docstrings + "black", "mkdocs-same-dir", "mdx-breakless-lists", "mdx-truly-sane-lists", "markdown-gfm-admonition", ] +[project.urls] +Homepage = "https://rl4.co" +Repository = "https://github.com/ai4co/rl4co" +Documentation = "https://rl4co.readthedocs.io" +Tracker = "https://github.com/ai4co/rl4co/issues" + +[tool.hatch.build.targets.sdist] +include = ["rl4co"] + +[tool.hatch.build.targets.wheel] +include = ["rl4co"] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + [tool.black] line-length = 90 target-version = ["py311"] @@ -180,7 +175,3 @@ exclude_lines = [ "pragma: no cover", "if __name__ == .__main__.:", ] - -[build-system] -requires = ["poetry"] -build-backend = "poetry.core.masonry.api" \ No newline at end of file From 841c937dda41746711e51c51ef1b8caadb57b7a8 Mon Sep 17 00:00:00 2001 From: Federico Berto Date: Tue, 14 Jan 2025 14:20:36 +0900 Subject: [PATCH 4/5] [Docs] add installation instructions with uv, poetry, conda --- README.md | 13 ++----- docs/content/start/installation.md | 56 ++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index d5249344..8a3b933f 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Lightning base: TorchRL config: Hydra -Code style: black +Code style: black Slack License: MIT Open In Colab @@ -89,7 +89,7 @@ git clone https://github.com/ai4co/rl4co && cd rl4co pip install -e . ``` -We recommend using a virtual environment such as `conda` to install `rl4co` locally. +We recommend installing in virtual environments with a package manager such as the blazing-fast [`uv`](https://docs.astral.sh/uv/), [`poetry`](https://python-poetry.org/), or [`conda`](https://docs.conda.io/en/latest/); instruction are available in the [documentation](https://rl4.co/docs/content/start/installation/). @@ -174,14 +174,7 @@ pytest tests ### Known Bugs - -#### Bugs installing PyTorch Geometric (PyG) - -Installing `PyG` via `Conda` seems to update Torch itself. We have found that this update introduces some bugs with `torchrl`. At this moment, we recommend installing `PyG` with `Pip`: -```bash -pip install torch_geometric -``` - +You may check out the [issues](https://github.com/ai4co/rl4co/issues) and [discussions](https://github.com/ai4co/rl4co/discussions). We will also periodically post updates on the [FAQ section](https://rl4.co/docs/content/general/faq/). ## Contributing diff --git a/docs/content/start/installation.md b/docs/content/start/installation.md index 69190f14..f7e356f3 100644 --- a/docs/content/start/installation.md +++ b/docs/content/start/installation.md @@ -8,14 +8,66 @@ pip install rl4co ``` ## Local install and development -If you want to develop RL4CO or access the latest builds, we recommend you to install it locally with `pip` in editable mode: +If you want to develop RL4CO or access the latest builds, you may install it locally after downloading the repo: ```bash git clone https://github.com/ai4co/rl4co && cd rl4co +``` + +The simplest way is via `pip` in editable mode with +```bash pip install -e . ``` -> Note: `conda` is also a good candidate for hassle-free installation of PyTorch: check out the [PyTorch website](https://pytorch.org/get-started/locally/) for more details. +To install optional dependencies, you may specify them as follows `pip install -e ".[dev,graph,routing,docs]"`. + +We recommend installing in virtual environments with a package manager such as the blazing-fast [`uv`](https://docs.astral.sh/uv/), [`poetry`](https://python-poetry.org/), or [`conda`](https://docs.conda.io/en/latest/), with quickstart commands below: + +
+ Install with `uv` + +You first need to install `uv`, i.e., with `pip`: +```bash +pip install uv +``` + +Then, you can create a virtual environment locally and activate it: +```bash +uv sync --frozen +source .venv/bin/activate +``` + +Note that `uv` directly generates the `.venv` folder in the current directory. + + +
+ + +
+ Install with `poetry` + +Make sure that you have `poetry` installed from the [official website](https://python-poetry.org/docs/). + +Then, you can create a virtual environment locally: +```bash +poetry install +poetry env activate # poetry shell removed in poetry 2.0.0 +``` + +Note: you need to upgrade `poetry` to the latest version with `poetry self update` to versions >=2.0.0 (see [blog post](https://python-poetry.org/blog/announcing-poetry-2.0.0/)). This is also the reason why we don't need a special `pyproject.toml` anymore. + +
+ + +
+ Install with `conda` + +After [installing `conda`](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html), you can create a virtual environment locally with: +```bash +conda create -n rl4co python=3.12 +conda activate rl4co +``` +
## Minimalistic Example From b76de4f5a316d7d0184ec4127c8364ab7de1580a Mon Sep 17 00:00:00 2001 From: Federico Berto Date: Tue, 14 Jan 2025 14:52:20 +0900 Subject: [PATCH 5/5] [Docs] add installation instructions with uv, poetry, conda --- docs/content/start/installation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/content/start/installation.md b/docs/content/start/installation.md index f7e356f3..3418feb1 100644 --- a/docs/content/start/installation.md +++ b/docs/content/start/installation.md @@ -40,6 +40,8 @@ source .venv/bin/activate Note that `uv` directly generates the `.venv` folder in the current directory. +To install (all) extras, you may use `uv sync --frozen --all-extras` or specify them individually with `uv sync --frozen --extra dev --extra graph --extra routing --extra docs`. +