Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom recipes use slash path #1760

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion torchtune/_cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ def _get_recipe(self, recipe_str: str) -> Optional[Recipe]:
if recipe.name == recipe_str:
return recipe

def _convert_to_dotpath(self, recipe_path: str) -> str:
"""Convert a custom recipe path to a dot path that can be run as a module.

Args:
recipe_path (str): The path of the recipe.

Returns:
The dot path of the recipe.
"""
filepath, _ = os.path.splitext(recipe_path)
return filepath.replace("/", ".")

def _get_config(
self, config_str: str, specific_recipe: Optional[Recipe]
) -> Optional[Config]:
Expand Down Expand Up @@ -163,7 +175,7 @@ def _run_cmd(self, args: argparse.Namespace):
# Get recipe path
recipe = self._get_recipe(args.recipe)
if recipe is None:
recipe_path = args.recipe
recipe_path = self._convert_to_dotpath(args.recipe)
is_builtin = False
else:
recipe_path = str(ROOT / "recipes" / recipe.file_path)
Expand Down
Loading