Skip to content

Commit 8f0ff6a

Browse files
Improve installation and remove unused code
* include uv ppm * update frontend dockerfile * update makefile * Update makefile, remove unused code, and improve logging
1 parent 5f10106 commit 8f0ff6a

13 files changed

+310
-501
lines changed

.gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ venv.bak/
118118
# Rope project settings
119119
.ropeproject
120120

121-
# poetry
122-
.poetry/
123-
poetry.lock
121+
# uv
122+
.venv/
123+
uv.lock
124124

125125
# mkdocs documentation
126126
/site

Dockerfile

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ RUN apt-get install -y curl net-tools iproute2 iputils-ping
2020
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2
2121
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 1
2222

23-
# Install pip
24-
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
25-
RUN python3.11 get-pip.py
26-
27-
RUN python3.11 -m pip install --upgrade pip setuptools virtualenv
28-
2923
# Install gcc and git
3024
RUN apt-get update && apt-get install -y build-essential gcc g++ clang git make cmake
3125

@@ -42,12 +36,18 @@ RUN apt-get update
4236

4337
RUN apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
4438

45-
RUN curl -sSL https://install.python-poetry.org | python3 -
39+
ADD https://astral.sh/uv/install.sh /uv-installer.sh
4640

47-
ENV PATH="${PATH}:/root/.local/bin"
41+
RUN sh /uv-installer.sh && rm /uv-installer.sh
4842

49-
ENV POETRY_VIRTUALENVS_CREATE=false
43+
ENV PATH="/root/.local/bin/:$PATH"
5044

5145
COPY pyproject.toml .
5246

53-
RUN poetry install --only core --no-root
47+
RUN uv python install 3.11.7
48+
49+
RUN uv python pin 3.11.7
50+
51+
RUN uv sync --group core
52+
53+
ENV PATH=".venv/bin:$PATH"

Makefile

+91-87
Original file line numberDiff line numberDiff line change
@@ -1,142 +1,146 @@
1-
POETRY_HOME := $(CURDIR)/.poetry
2-
POETRY := $(POETRY_HOME)/bin/poetry
3-
4-
MIN_PYTHON_VERSION := 3.10
5-
6-
PYTHON_VERSIONS := 3.11 3.10
7-
8-
PYTHON := $(shell \
9-
for ver in $(PYTHON_VERSIONS); do \
10-
if command -v python$$ver >/dev/null 2>&1; then echo python$$ver; exit 0; fi; \
11-
done \
12-
)
13-
14-
ifndef PYTHON
15-
$(error "Python version $(MIN_PYTHON_VERSION) or higher is required but not found.")
16-
endif
17-
18-
.PHONY: pre-install
19-
pre-install:
20-
@echo "🐍 Using Python interpreter: $(PYTHON)"
21-
@echo "🐍 Checking if Python is installed"
22-
@command -v $(PYTHON) >/dev/null 2>&1 || { echo >&2 "$(PYTHON) is not installed. Aborting."; exit 1; }
23-
@echo "🐍 Checking Python version"
24-
@$(PYTHON) --version | grep -E "Python 3\.(1[0-9]|[2-9][0-9])" >/dev/null 2>&1 || { echo >&2 "Python $(MIN_PYTHON_VERSION) or higher is required. Aborting."; exit 1; }
25-
@echo "📦 Checking if Poetry is installed"
26-
@if ! command -v poetry >/dev/null 2>&1 || [ ! -d "$(POETRY_HOME)" ]; then \
27-
echo "Poetry is not installed or POETRY_HOME does not exist. Installing Poetry."; \
28-
curl -sSL https://install.python-poetry.org | POETRY_HOME=$(POETRY_HOME) $(PYTHON) -; \
29-
fi
30-
@echo "📦 Configuring Poetry"
31-
@if [ -z "$$CONDA_PREFIX" ] && [ -z "$$VIRTUAL_ENV" ]; then \
32-
echo "Configuring Poetry to create a virtual environment."; \
33-
$(POETRY) config virtualenvs.in-project true; \
1+
UV := uv
2+
PYTHON_VERSION := 3.11
3+
UV_INSTALL_SCRIPT := https://astral.sh/uv/install.sh
4+
5+
command_exists = $(shell command -v $(1) >/dev/null 2>&1 && echo true || echo false)
6+
7+
define install_uv
8+
@echo "📦 uv is not installed. Installing uv..."
9+
@curl -LsSf $(UV_INSTALL_SCRIPT) | sh
10+
endef
11+
12+
.PHONY: check-uv
13+
check-uv: ## Check and install uv if necessary
14+
@if command -v $(UV) >/dev/null 2>&1; then \
15+
echo "📦 uv is already installed."; \
3416
else \
35-
echo "Configuring Poetry to use the existing environment."; \
36-
$(POETRY) config virtualenvs.create false; \
17+
echo "📦 uv is not installed. Installing uv..."; \
18+
curl -LsSf $(UV_INSTALL_SCRIPT) | sh; \
3719
fi
38-
@echo "📦 Setting Poetry to use $(PYTHON)"
39-
@$(POETRY) env use $(PYTHON) || { echo "Failed to set Python version for Poetry. Aborting."; exit 1; }
20+
21+
.PHONY: install-python
22+
install-python: check-uv ## Install Python with uv
23+
@echo "🐍 Installing Python $(PYTHON_VERSION) with uv"
24+
@$(UV) python install $(PYTHON_VERSION)
25+
@echo "🔧 Configuring Python $(PYTHON_VERSION) as the default Python version"
26+
@$(UV) python pin $(PYTHON_VERSION)
4027

4128
.PHONY: install
42-
install: pre-install ## Install the poetry environment and install the pre-commit hooks
43-
@echo "📦 Installing dependencies with Poetry"
44-
@PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring $(POETRY) install --with core
29+
install: install-python ## Install core dependencies
30+
@echo "📦 Installing core dependencies with uv"
31+
@$(UV) sync --group core
4532
@echo "🔧 Installing pre-commit hooks"
46-
@$(POETRY) run pre-commit install
33+
@$(UV) run pre-commit install
34+
@echo ""
35+
@echo "🐳 Building nebula-frontend docker image. Do you want to continue? (y/n)"
36+
@read ans && [ $${ans:-N} = y ] || { echo "Build cancelled."; exit 1; }
37+
@docker build -t nebula-frontend -f nebula/frontend/Dockerfile .
38+
@echo ""
39+
@echo "🐳 Building nebula-core docker image. Do you want to continue? (y/n)"
40+
@read ans && [ $${ans:-N} = y ] || { echo "Build cancelled."; exit 1; }
41+
@docker build -t nebula-core .
42+
@echo ""
4743
@$(MAKE) shell
4844

4945
.PHONY: full-install
50-
full-install: pre-install ## Install the poetry environment and install the pre-commit hooks
51-
@echo "📦 Installing dependencies with Poetry"
52-
@PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring $(POETRY) install --with core,docs,dev
46+
full-install: install-python ## Install all dependencies (core, docs)
47+
@echo "📦 Installing all dependencies with uv"
48+
@$(UV) sync --group core --group docs
5349
@echo "🔧 Installing pre-commit hooks"
54-
@$(POETRY) run pre-commit install
50+
@$(UV) run pre-commit install
5551
@$(MAKE) shell
5652

5753
.PHONY: shell
58-
shell: ## Start a shell in the poetry environment
59-
@if [ -z "$$CONDA_PREFIX" ] && [ -z "$$VIRTUAL_ENV" ]; then \
60-
echo "🐚 Activating virtual environment"; \
61-
$(POETRY) shell; \
54+
shell: ## Start a shell in the uv environment
55+
@echo "🐚 Starting a shell in the uv environment"
56+
@if [ -n "$$VIRTUAL_ENV" ]; then \
57+
echo "🐚 Already in a virtual environment: $$VIRTUAL_ENV"; \
58+
elif [ ! -d ".venv" ]; then \
59+
echo "❌ .venv directory not found. Running 'make install' to create it..."; \
60+
$(MAKE) install; \
6261
else \
63-
echo "🐚 Conda or virtual environment detected, skipping Poetry shell activation"; \
62+
echo "🐚 Run the following command to activate the virtual environment:"; \
63+
echo ""; \
64+
echo '[Linux/MacOS] \033[1;32msource .venv/bin/activate\033[0m'; \
65+
echo '[Windows] \033[1;32m.venv\\bin\\activate\033[0m'; \
66+
echo ""; \
67+
echo "🚀 NEBULA is ready to use!"; \
68+
echo "🚀 Created by \033[1;34mEnrique Tomás Martínez Beltrán\033[0m <\033[1;[email protected]\033[0m>"; \
6469
fi
6570

66-
.PHONY: sync
67-
sync: ## Sync the lock file
68-
@echo "📦 Syncing the lock file"
69-
@PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring $(POETRY) lock
71+
.PHONY: lock
72+
lock: ## Update the lock file
73+
@echo "🔒 This will update the lock file. Do you want to continue? (y/n)"
74+
@read ans && [ $${ans:-N} = y ] || { echo "Lock cancelled."; exit 1; }
75+
@echo "🔒 Locking dependencies..."
76+
@$(UV) lock
7077

7178
.PHONY: update-libs
72-
update-libs: ## Update libraries to the latest version
73-
@echo "🔧 This will override the version of current libraries. Do you want to continue? (y/n)"
79+
update-libs: ## Update libraries to the latest version
80+
@echo "🔧 This will override the versions of current libraries. Do you want to continue? (y/n)"
7481
@read ans && [ $${ans:-N} = y ] || { echo "Update cancelled."; exit 1; }
7582
@echo "📦 Updating libraries..."
76-
@PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring $(POETRY) update
83+
@$(UV) update
7784

7885
.PHONY: check
79-
check: ## Run code quality tools.
86+
check: ## Run code quality tools
8087
@echo "🛠️ Running code quality checks"
81-
@echo "🔍 Checking Poetry lock file consistency"
82-
@$(POETRY) check --lock
88+
@echo "🔍 Checking uv lock file consistency"
89+
@$(UV) sync
8390
@echo "🚨 Linting code with pre-commit"
84-
@$(POETRY) run pre-commit run -a
91+
@$(UV) run pre-commit run -a
8592

8693
.PHONY: check-plus
87-
check-plus: check ## Run additional code quality tools.
88-
@echo "🔍 Checking code formatting with black
89-
@$(POETRY) run black --check ."
94+
check-plus: check ## Run additional code quality tools
95+
@echo "🔍 Checking code formatting with black"
96+
@$(UV) run black --check .
9097
@echo "⚙️ Static type checking with mypy"
91-
@$(POETRY) run mypy
98+
@$(UV) run mypy
9299
@echo "🔎 Checking for obsolete dependencies"
93-
@$(POETRY) run deptry .
100+
@$(UV) run deptry .
94101

95102
.PHONY: build
96-
build: clean-build ## Build wheel file using poetry
103+
build: clean-build ## Build the wheel file
97104
@echo "🚀 Creating wheel file"
98-
@$(POETRY) build
105+
@$(UV) build
99106

100107
.PHONY: clean-build
101-
clean-build: ## clean build artifacts
108+
clean-build: ## Clean build artifacts
102109
@rm -rf dist
103110

104111
.PHONY: publish
105-
publish: ## publish a release to pypi.
106-
@echo "🚀 Publishing: Dry run."
107-
@$(POETRY) config pypi-token.pypi $(PYPI_TOKEN)
108-
@$(POETRY) publish --dry-run
109-
@echo "🚀 Publishing."
110-
@$(POETRY) publish
112+
publish: ## Publish a release to PyPI
113+
@echo "🚀 Publishing...""
114+
@$(UV) publish --token $(PYPI_TOKEN)
111115

112116
.PHONY: build-and-publish
113-
build-and-publish: build publish ## Build and publish.
117+
build-and-publish: build publish ## Build and publish the package
114118

115119
.PHONY: doc-test
116-
doc-test: ## Test if documentation can be built without warnings or errors
117-
@$(POETRY) run mkdocs build -f docs/mkdocs.yml -d _build -s
120+
doc-test: ## Test if documentation can be built without errors
121+
@$(UV) run mkdocs build -f docs/mkdocs.yml -d _build -s
118122

119123
.PHONY: doc-build
120-
doc-build: ## Build the documentation
121-
@$(POETRY) run mkdocs build -f docs/mkdocs.yml -d _build
124+
doc-build: ## Build the documentation
125+
@$(UV) run mkdocs build -f docs/mkdocs.yml -d _build
122126

123127
.PHONY: doc-serve
124-
doc-serve: ## Build and serve the documentation
125-
@$(POETRY) run mkdocs serve -f docs/mkdocs.yml
128+
doc-serve: ## Serve the documentation locally
129+
@$(UV) run mkdocs serve -f docs/mkdocs.yml
126130

127131
.PHONY: format
128-
format: ## Format code with black and isort
132+
format: ## Format code with black and isort
129133
@echo "🎨 Formatting code"
130-
@$(POETRY) run black .
131-
@$(POETRY) run isort .
134+
@$(UV) run black .
135+
@$(UV) run isort .
132136

133137
.PHONY: clean
134-
clean: clean-build ## Clean up build artifacts and cache files
138+
clean: clean-build ## Clean up build artifacts and caches
135139
@echo "🧹 Cleaning up build artifacts and caches"
136140
@rm -rf __pycache__ */__pycache__ .mypy_cache
137141

138142
.PHONY: help
139-
help:
143+
help: ## Display available commands
140144
@echo "Available commands:"
141145
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "💡 \033[36m%-20s\033[0m %s\n", $$1, $$2}'
142146

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Distributed under the GNU GPLv3 License. See `LICENSE` for more information.
147147
We would like to thank the following projects for their contributions which have helped shape NEBULA:
148148

149149
- [PyTorch Lightning](https://github.com/Lightning-AI/pytorch-lightning) for the training loop and model management
150-
- [Tensorboard](https://github.com/tensorflow/tensorboard) and [Aim](https://github.com/aimhubio/aim) for the visualization tools and monitoring capabilities
150+
- [Tensorboard](https://github.com/tensorflow/tensorboard) for the visualization tools and monitoring capabilities
151151
- Different datasets ([nebula/core/datasets](https://github.com/CyberDataLab/nebula/tree/main/nebula/core/datasets)) and models ([nebula/core/models](https://github.com/CyberDataLab/nebula/tree/main/nebula/core/models)) for testing and validation purposes
152152
- [FastAPI](https://github.com/tiangolo/fastapi) for the RESTful API
153153
- [Web3](https://github.com/ethereum/web3.py) for the blockchain integration

app/logs/server.log

Whitespace-only changes.

nebula/controller.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ def run_frontend(self):
525525
- NEBULA_PRODUCTION={production}
526526
- NEBULA_GPU_AVAILABLE={gpu_available}
527527
- NEBULA_ADVANCED_ANALYTICS={advanced_analytics}
528-
- SERVER_LOG=/nebula/app/logs/server.log
528+
- NEBULA_SERVER_LOG=/nebula/app/logs/server.log
529529
- NEBULA_LOGS_DIR=/nebula/app/logs/
530530
- NEBULA_CONFIG_DIR=/nebula/app/config/
531531
- NEBULA_CERTS_DIR=/nebula/app/certs/

nebula/core/engine.py

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
logging.getLogger("urllib3").setLevel(logging.WARNING)
1818
logging.getLogger("fsspec").setLevel(logging.WARNING)
1919
logging.getLogger("matplotlib").setLevel(logging.ERROR)
20-
logging.getLogger("aim").setLevel(logging.ERROR)
2120
logging.getLogger("plotly").setLevel(logging.ERROR)
2221

2322
import pdb

nebula/core/training/lightning.py

+1-23
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,10 @@
1616
from lightning.pytorch.loggers import CSVLogger
1717
from torch.nn import functional as F
1818

19+
from nebula.config.config import TRAINING_LOGGER
1920
from nebula.core.utils.deterministic import enable_deterministic
2021
from nebula.core.utils.nebulalogger_tensorboard import NebulaTensorBoardLogger
2122

22-
try:
23-
from nebula.core.utils.nebulalogger import NebulaLogger
24-
except:
25-
pass
26-
from nebula.config.config import TRAINING_LOGGER
27-
2823
logging_training = logging.getLogger(TRAINING_LOGGER)
2924

3025

@@ -170,23 +165,6 @@ def create_logger(self):
170165
)
171166
# Restore logger configuration
172167
nebulalogger.set_logger_config(logger_config)
173-
elif self.config.participant["tracking_args"]["local_tracking"] == "advanced":
174-
nebulalogger = NebulaLogger(
175-
config=self.config,
176-
engine=self,
177-
scenario_start_time=self.config.participant["scenario_args"]["start_time"],
178-
repo=f"{self.config.participant['tracking_args']['log_dir']}",
179-
experiment=self.experiment_name,
180-
run_name=f"participant_{self.idx}",
181-
train_metric_prefix="train_",
182-
test_metric_prefix="test_",
183-
val_metric_prefix="val_",
184-
log_system_params=False,
185-
)
186-
# nebulalogger_aim = NebulaLogger(config=self.config, engine=self, scenario_start_time=self.config.participant["scenario_args"]["start_time"], repo=f"aim://nebula-frontend:8085",
187-
# experiment=self.experiment_name, run_name=f"participant_{self.idx}",
188-
# train_metric_prefix='train_', test_metric_prefix='test_', val_metric_prefix='val_', log_system_params=False)
189-
self.config.participant["tracking_args"]["run_hash"] = nebulalogger.experiment.hash
190168
else:
191169
nebulalogger = None
192170

nebula/core/utils/nebulalogger.py

-44
This file was deleted.

0 commit comments

Comments
 (0)