generated from fastai/nbdev_template
-
Notifications
You must be signed in to change notification settings - Fork 280
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
move nbdev detection to fastcore #627
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Utilities for the nbdev library.""" | ||
|
||
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/13_nbdev.ipynb. | ||
|
||
# %% auto 0 | ||
__all__ = ['nbdev_config_file', 'is_nbdev'] | ||
|
||
# %% ../nbs/13_nbdev.ipynb | ||
from .basics import Path | ||
|
||
# %% ../nbs/13_nbdev.ipynb | ||
_nbdev_cfg_name = 'settings.ini' | ||
|
||
def nbdev_config_file(cfg_name=_nbdev_cfg_name, path=None): | ||
"Get the nbdev config file path" | ||
cfg_path = path = Path.cwd() if path is None else Path(path) | ||
while cfg_path != cfg_path.parent and not (cfg_path/cfg_name).exists(): cfg_path = cfg_path.parent | ||
if not (cfg_path/cfg_name).exists(): cfg_path = path | ||
return cfg_path/cfg_name | ||
|
||
# %% ../nbs/13_nbdev.ipynb | ||
def is_nbdev(): | ||
"Checks if the current directory is in a nbdev project." | ||
return nbdev_config_file().exists() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7bea0d2f", | ||
"metadata": {}, | ||
"source": [ | ||
"# nbdev utilities\n", | ||
"> Utilities for the nbdev library." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "07a035a5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|default_exp nbdev" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "75e11db6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|export\n", | ||
"from fastcore.basics import Path" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "558b4d4c", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|hide\n", | ||
"from nbdev.export import *\n", | ||
"from fastcore.test import *" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "da2ac196", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|export\n", | ||
"_nbdev_cfg_name = 'settings.ini'\n", | ||
"\n", | ||
"def nbdev_config_file(cfg_name=_nbdev_cfg_name, path=None):\n", | ||
" \"Get the nbdev config file path\"\n", | ||
" cfg_path = path = Path.cwd() if path is None else Path(path)\n", | ||
" while cfg_path != cfg_path.parent and not (cfg_path/cfg_name).exists(): cfg_path = cfg_path.parent\n", | ||
" if not (cfg_path/cfg_name).exists(): cfg_path = path\n", | ||
" return cfg_path/cfg_name" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1c44a414", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|export\n", | ||
"def is_nbdev(): \n", | ||
" \"Checks if the current directory is in a nbdev project.\"\n", | ||
" return nbdev_config_file().exists()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "604a2243", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|hide\n", | ||
"test_eq(is_nbdev(), True)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "df973d4e", | ||
"metadata": {}, | ||
"source": [ | ||
"# Export -" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "914d16ca", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"#|hide\n", | ||
"import nbdev; nbdev.nbdev_export()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "20a20020", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "python3", | ||
"language": "python", | ||
"name": "python3" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would normally make this a one-liner, but I think having a a docstring is good for LLMs?