Skip to content

Commit

Permalink
[release] version 3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tamoyan committed Jan 21, 2025
1 parent bda2c5c commit 9720f9e
Show file tree
Hide file tree
Showing 23 changed files with 155 additions and 1,823 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ ipython_config.py
.logs
.aim
outputs
runs
models--*
.DS_Store
Icon*
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

<!--- BADGES: END --->

🚀 New Release Available!
We've just rolled out a new version of this project! 🎉 While the README.md is still catching up with all the exciting changes, feel free to explore the release notes and dive in. Your feedback is always welcome! ❤️

# UrarTU 🦁

Harness the power of UrarTU, a versatile ML framework meticulously designed to provide intuitive abstractions of familiar pipeline components. With a `.yaml` file-based configuration system, and the added convenience of seamless `slurm` job submission on clusters, `UrarTU` takes the complexity out of machine learning, so you can focus on what truly matters! 🚀
Expand All @@ -19,7 +22,9 @@ Getting Started with `UrarTU` is a Breeze! 🌀 Simply do
pip install urartu
```

Or follow these steps to install from the source:


<!-- Or follow these steps to install from the source:
- Clone the repository: `git clone git@github.com:tamohannes/urartu.git`
- Navigate to the project directory: `cd urartu`
Expand Down Expand Up @@ -75,7 +80,7 @@ Tailoring configurations to your needs is a breeze with UrarTU. You have two fle
2. **CLI Approach**: For those who prefer a command-line interface (CLI) approach, UrarTU offers a convenient method. You can enhance your commands with specific key-value pairs directly in the CLI. For example, modifying your working directory path is as simple as:
```bash
urartu action_config=example action_config.workdir=PATH_TO_WORKDIR
urartu action_config=example action_config.experiment_name=NAME_OF_EXPERIMENT
```
Choose the method that suits your workflow best and enjoy the flexibility UrarTU provides for crafting custom configurations.
Expand Down Expand Up @@ -125,4 +130,4 @@ Unveiling Insights with Ease! 🔍 UrarTU, pairs up with [Aim](https://github.co
```bash
aim up
```
Behold as your experiments come to life with clarity and depth! Aim brings your data to the forefront, and with it, the power to make informed decisions and chart new territories in the realm of machine learning. 📈
Behold as your experiments come to life with clarity and depth! Aim brings your data to the forefront, and with it, the power to make informed decisions and chart new territories in the realm of machine learning. 📈 -->
1 change: 0 additions & 1 deletion getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ aim:
repo: ./

action_config:
workdir: ./
experiment_name: "Example - next token prediction"
device: "cpu" # auto, cuda, cpu (default)

Expand Down
2 changes: 1 addition & 1 deletion urartu/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.28
3.0.0
119 changes: 116 additions & 3 deletions urartu/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,117 @@
from .commands import main
import os
import sys
import logging
import secrets

if __name__ == "__main__":
main()
from aim import Run
from hydra import compose, initialize
from hydra.core.plugins import Plugins
from hydra.core.hydra_config import HydraConfig
from omegaconf import OmegaConf
from pathlib import Path
from datetime import datetime

from urartu.utils.launcher import launch, launch_on_slurm
from urartu.utils.hydra_plugin import UrartuPlugin

Plugins.instance().register(UrartuPlugin)


import hydra
from omegaconf import DictConfig


@hydra.main(version_base=None, config_path="config", config_name="main")
def main(cfg: DictConfig) -> None:
hydra_cfg = HydraConfig.get()
cfg = OmegaConf.create(OmegaConf.to_container(cfg, resolve=True, enum_to_str=True))

cwd = Path.cwd()

is_module = cwd.joinpath('__init__.py').exists()
if not is_module:
logging.error(
f"The directory '{cwd}' is not recognized as a Python module because it lacks an '__init__.py' file."
" To resolve this issue, ensure that an '__init__.py' file exists in the directory if it's intended to be a Python module."
)
raise FileNotFoundError("Missing '__init__.py' file.")

are_actions = cwd.joinpath('actions').is_dir()
if not are_actions:
logging.error(
f"The required 'actions' subdirectory does not exist in the directory '{cwd}'."
" Please ensure that an 'actions' directory is created within the current directory to proceed."
)
raise FileNotFoundError("Missing 'actions' directory.")

action_file_path = cwd.joinpath('actions', f"{cfg.action_name}.py")
if action_file_path.exists():
logging.info(f"The action file '{action_file_path}' is located and is ready to be used!")
else:
logging.error(
f"The action file '{action_file_path}' does not exist."
" Please ensure that the file is correctly named and located in the 'actions' directory."
)
raise FileNotFoundError("Missing action file.")

is_multirun = hydra_cfg.mode.name == "MULTIRUN"

if is_multirun:
run_dir = Path(hydra_cfg.runtime.output_dir, hydra_cfg.job.id).parent
else:
run_dir = cwd.joinpath(".runs", datetime.now().strftime("%Y-%m-%d_%H-%M-%S"))
os.makedirs(run_dir, exist_ok=True)

run_hash = secrets.token_hex(8)

log_file = run_dir / "output.log"
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[logging.FileHandler(log_file), logging.StreamHandler()],
)

# Redirect stdout and stderr to log file
sys.stdout = open(log_file, 'a')
sys.stderr = sys.stdout

cfg.action_config.run_dir = str(run_dir)
cfg.action_config.run_hash = run_hash

with open(run_dir / "notes.md", "w") as f:
pass

with open(run_dir / "cfg.yaml", "w") as f:
OmegaConf.save(config=cfg, f=f)

aim_run = None
if cfg.aim.use_aim:
aim_run = Run(
repo=cfg.aim.repo,
experiment=cfg.action_config.experiment_name,
log_system_params=cfg.aim.log_system_params,
)
aim_run.set("cfg", cfg, strict=False)

if cfg.slurm.use_slurm:
try:
import submitit # NOQA
except ImportError:
raise ImportError("Please 'pip install submitit' to schedule jobs on SLURM")

launch_on_slurm(
module=cwd,
action_name=cfg.action_name,
cfg=cfg,
aim_run=aim_run,
)
else:
launch(
module=cwd,
action_name=cfg.action_name,
cfg=cfg,
aim_run=aim_run,
)

if cfg.aim.use_aim and aim_run.active:
aim_run.close()
36 changes: 0 additions & 36 deletions urartu/commands/__init__.py

This file was deleted.

43 changes: 0 additions & 43 deletions urartu/commands/command.py

This file was deleted.

82 changes: 0 additions & 82 deletions urartu/commands/launch.py

This file was deleted.

36 changes: 0 additions & 36 deletions urartu/commands/register.py

This file was deleted.

Loading

0 comments on commit 9720f9e

Please sign in to comment.