diff --git a/nbdev/_modidx.py b/nbdev/_modidx.py index 0080af3a5..83b2343ba 100644 --- a/nbdev/_modidx.py +++ b/nbdev/_modidx.py @@ -41,6 +41,7 @@ 'nbdev_release_both=nbdev.release:release_both\n' 'nbdev_help=nbdev.shortcuts:chelp', 'copyright': '2020 onwards, Jeremy Howard', + 'custom_quarto_yml': 'False', 'custom_sidebar': 'True', 'description': 'Create delightful software with Jupyter Notebooks', 'dev_requirements': 'nbdev-numpy nbdev-stdlib pandas matplotlib black', diff --git a/nbdev/clean.py b/nbdev/clean.py index d6a89edf4..9b9434681 100644 --- a/nbdev/clean.py +++ b/nbdev/clean.py @@ -31,7 +31,7 @@ def nbdev_trust( warnings.warn("Please install jupyter and try again") return - fname = Path(fname if fname else config_key("nbs_path")) + fname = Path(fname if fname else get_config().path('nbs_path')) path = fname if fname.is_dir() else fname.parent check_fname = path/".last_checked" last_checked = os.path.getmtime(check_fname) if check_fname.exists() else None @@ -133,7 +133,7 @@ def nbdev_clean( _write = partial(process_write, warn_msg='Failed to clean notebook', proc_nb=_clean) if stdin: return _write(f_in=sys.stdin, f_out=sys.stdout) - if fname is None: fname = config_key("nbs_path") + if fname is None: fname = get_config().path('nbs_path') for f in globtastic(fname, file_glob='*.ipynb', skip_folder_re='^[_.]'): _write(f_in=f, disp=disp) # %% ../nbs/11_clean.ipynb 30 diff --git a/nbdev/cli.py b/nbdev/cli.py index d5637587a..8115b7b1a 100644 --- a/nbdev/cli.py +++ b/nbdev/cli.py @@ -33,7 +33,7 @@ def nbdev_ghp_deploy(): except: warnings.warn('Please install ghp-import with `pip install ghp-import`') return - ghp_import(config_key('doc_path'), push=True, stderr=True, no_history=True) + ghp_import(get_config().path('doc_path'), push=True, stderr=True, no_history=True) # %% ../nbs/10_cli.ipynb 7 _def_file_re = '\.(?:ipynb|qmd|html)$' @@ -60,8 +60,8 @@ def nbdev_sidebar( returnit:bool=False # Return list of files found ): "Create sidebar.yml" - if not force and str2bool(config_key('custom_sidebar', path=False)): return - path = config_key("nbs_path") if not path else Path(path) + if not force and str2bool(get_config().custom_sidebar): return + path = get_config().path('nbs_path') if not path else Path(path) files = nbglob(path, func=_f, symlinks=symlinks, file_re=file_re, folder_re=folder_re, file_glob=file_glob, skip_file_glob=skip_file_glob, skip_file_re=skip_file_re, skip_folder_re=skip_folder_re).sorted(key=_sort) lastd,res = Path(),[] @@ -271,7 +271,7 @@ def refresh_quarto_yml(): p = cfg.path('nbs_path')/'_quarto.yml' vals = {k:cfg.get(k) for k in ['doc_path', 'title', 'description', 'branch', 'git_url', 'doc_host', 'doc_baseurl']} # Do not build _quarto_yml if custom_quarto_yml is set to True - if str2bool(config_key('custom_quarto_yml', default="False", path=False)): return + if str2bool(get_config().custom_quarto_yml): return if 'title' not in vals: vals['title'] = vals['lib_name'] yml=_quarto_yml.format(**vals) p.write_text(yml) @@ -318,14 +318,14 @@ def _sprun(cmd): def _doc_paths(path:str=None, doc_path:str=None): cfg = get_config() cfg_path = cfg.config_path - path = config_key("nbs_path") if not path else Path(path) - doc_path = config_key("doc_path") if not doc_path else Path(doc_path) + path = cfg.path('nbs_path') if not path else Path(path) + doc_path = cfg.path('doc_path') if not doc_path else Path(doc_path) tmp_doc_path = path/f"{cfg['doc_path']}" return cfg,cfg_path,path,doc_path,tmp_doc_path # %% ../nbs/10_cli.ipynb 28 def _render_readme(path): - idx_path = path/config_key('readme_nb', path=False) + idx_path = path/get_config().readme_nb if not idx_path.exists(): return yml_path = path/'sidebar.yml' diff --git a/nbdev/doclinks.py b/nbdev/doclinks.py index 252288963..c37248676 100644 --- a/nbdev/doclinks.py +++ b/nbdev/doclinks.py @@ -108,10 +108,10 @@ def _doc_link(url, mod, sym=None): # %% ../nbs/04b_doclinks.ipynb 27 def build_modidx(): "Create _modidx.py" - dest = config_key('lib_path') + dest = get_config().path('lib_path') if os.environ.get('IN_TEST',0): return _fn = dest/'_modidx.py' - nbs_path = config_key('nbs_path') + nbs_path = get_config().path('nbs_path') with contextlib.suppress(FileNotFoundError): _fn.unlink() cfg = get_config() doc_func = partial(_doc_link, urljoin(cfg.doc_host,cfg.doc_baseurl)) @@ -122,9 +122,9 @@ def build_modidx(): @delegates(globtastic, but=['file_glob', 'skip_folder_re']) def nbglob(path=None, skip_folder_re = '^[_.]', file_glob='*.ipynb', recursive=True, key='nbs_path', as_path=False, **kwargs): - "Find all files in a directory matching an extension given a `config_key`." - path = Path(path or config_key(key)) - if recursive is None: recursive=str2bool(config_key('recursive', path=False)) + "Find all files in a directory matching an extension given a config key." + path = Path(path or get_config().path(key)) + if recursive is None: recursive=str2bool(get_config().recursive) res = globtastic(path, file_glob=file_glob, skip_folder_re=skip_folder_re, **kwargs) return res.map(Path) if as_path else res diff --git a/nbdev/migrate.py b/nbdev/migrate.py index 9afb1a788..25de72b54 100644 --- a/nbdev/migrate.py +++ b/nbdev/migrate.py @@ -6,7 +6,7 @@ # %% ../nbs/15_migrate.ipynb 2 from .process import first_code_ln from .processors import nb_fmdict, construct_fm, insert_frontmatter, is_frontmatter, yml2dict, filter_fm -from .read import read_nb, config_key +from .read import get_config, read_nb from .sync import write_nb from .clean import process_write from .showdoc import show_doc @@ -75,7 +75,7 @@ def _subv1(s): return _alias.get(s, s) def _re_v1(): d = ['default_exp', 'export', 'exports', 'exporti', 'hide', 'hide_input', 'collapse_show', 'collapse', 'collapse_hide', 'collapse_input', 'hide_output', 'default_cls_lvl'] - d += L(config_key('tst_flags', path=False)).filter() + d += L(get_config().tst_flags).filter() d += [s.replace('_', '-') for s in d] # allow for hyphenated version of old directives _tmp = '|'.join(list(set(d))) return re.compile(f"^[ \f\v\t]*?(#)\s*({_tmp})(?!\S)", re.MULTILINE) @@ -123,5 +123,5 @@ def nbdev_migrate( _write = partial(process_write, warn_msg='Failed to replace directives', proc_nb=_migrate) if stdin: _write(f_in=sys.stdin, f_out=sys.stdout) _skip_re = None if no_skip else '^[_.]' - if fname is None: fname = config_key("nbs_path") + if fname is None: fname = get_config().path('nbs_path') for f in globtastic(fname, file_glob='*.ipynb', skip_folder_re=_skip_re): _write(f_in=f, disp=disp) diff --git a/nbdev/read.py b/nbdev/read.py index 185133587..cbf1209e5 100644 --- a/nbdev/read.py +++ b/nbdev/read.py @@ -40,7 +40,7 @@ def apply_defaults( lib_name:str=None, # Package name, defaults to local repo folder name branch='master', # Repo default branch git_url='https://github.com/%(user)s/%(lib_name)s', # Repo URL - custom_sidebar:bool_arg=False, # Create custom sidebar? + custom_sidebar:bool_arg=False, # Use a custom sidebar.yml? nbs_path='.', # Path to notebooks lib_path='%(lib_name)s', # Path to package root doc_path='_docs', # Path to rendered docs @@ -63,6 +63,7 @@ def apply_defaults( allowed_cell_metadata_keys='', # Preserve the list of keys in cell level metadata jupyter_hooks=True, # Run Jupyter hooks? clean_ids=True, # Remove ids from plaintext reprs? + custom_quarto_yml=False, # Use a custom _quarto.yml? ): "Apply default settings where missing in `cfg`" if lib_name is None: @@ -114,13 +115,9 @@ def get_config(cfg_name=_nbdev_config_name, path=None): # %% ../nbs/01_read.ipynb 21 def config_key(c, default=None, path=True, missing_ok=None): - "Look for key `c` in settings.ini and fail gracefully if not found and no default provided" - if missing_ok is not None: - warn("`missing_ok` is no longer used. Don't pass it to `config_key` to silence this warning.") - cfg = get_config() - res = cfg.path(c, default) if path else cfg.get(c, default) - if res is None: raise ValueError(f'`{c}` not specified in {_nbdev_config_name}') - return res + "Deprecated: use `get_config().get` or `get_config().path` instead." + warn("`config_key` is deprecated. Use `get_config().get` or `get_config().path` instead.", DeprecationWarning) + return get_config().path(c, default) if path else get_config().get(c, default) # %% ../nbs/01_read.ipynb 24 _init = '__init__.py' @@ -147,7 +144,7 @@ def write_cells(cells, hdr, file, offset=0): # %% ../nbs/01_read.ipynb 29 def basic_export_nb(fname, name, dest=None): "Basic exporter to bootstrap nbdev" - if dest is None: dest = config_key('lib_path') + if dest is None: dest = get_config().path('lib_path') fname,dest = Path(fname),Path(dest) nb = read_nb(fname) diff --git a/nbdev/release.py b/nbdev/release.py index f4222d37f..d7708680d 100644 --- a/nbdev/release.py +++ b/nbdev/release.py @@ -256,7 +256,7 @@ def release_conda( upload_user:str=None # Optional user to upload package to ): "Create a `meta.yaml` file ready to be built into a package, and optionally build and upload it" - name = config_key('lib_name', path=False) + name = get_config().lib_name write_conda_meta(path) out = f"Done. Next steps:\n```\ncd {path}\n""" os.chdir(path) @@ -268,7 +268,7 @@ def release_conda( print(f"conda {build} --no-anaconda-upload {build_args} {name}") res = _run(f"conda {build} --no-anaconda-upload {build_args} {name}") if skip_upload: return - if not upload_user: upload_user = config_key('conda_user', path=False) + if not upload_user: upload_user = get_config().conda_user if not upload_user: return print("`conda_user` not in settings.ini and no `upload_user` passed. Cannot upload") if 'anaconda upload' not in res: return print(f"{res}\n\Failed. Check auto-upload not set in .condarc. Try `--do_build False`.") return anaconda_upload(name, loc) @@ -293,7 +293,7 @@ def release_pypi( repository:str="pypi" # Respository to upload to (defined in ~/.pypirc) ): "Create and upload Python package to PyPI" - _dir = config_key("lib_path").parent + _dir = get_config().path('lib_path').parent system(f'cd {_dir} && rm -rf dist && python setup.py sdist bdist_wheel') system(f'twine upload --repository {repository} {_dir}/dist/*') diff --git a/nbdev/test.py b/nbdev/test.py index e27d49a22..912e7d622 100644 --- a/nbdev/test.py +++ b/nbdev/test.py @@ -81,7 +81,7 @@ def nbdev_test( ignore_fname:str='.notest' # Filename that will result in siblings being ignored ): "Test in parallel notebooks matching `fname`, passing along `flags`" - skip_flags = config_key('tst_flags', path=False).split() + skip_flags = get_config().tst_flags.split() force_flags = flags.split() files = nbglob(fname, recursive=recursive, file_re=file_re, folder_re=folder_re, skip_file_glob=skip_file_glob, skip_file_re=skip_file_re, as_path=True, symlinks=symlinks) @@ -89,7 +89,7 @@ def nbdev_test( if len(files)==0: return print('No files were eligible for testing') if n_workers is None: n_workers = 0 if len(files)==1 else min(num_cpus(), 8) - os.chdir(config_key("nbs_path")) + os.chdir(get_config().path('nbs_path')) if IN_NOTEBOOK: kwargs = {'method':'spawn'} if os.name=='nt' else {'method':'forkserver'} else: kwargs = {} results = parallel(test_nb, files, skip_flags=skip_flags, force_flags=force_flags, n_workers=n_workers, diff --git a/nbs/01_read.ipynb b/nbs/01_read.ipynb index c3ae2f5a3..0dfcde041 100644 --- a/nbs/01_read.ipynb +++ b/nbs/01_read.ipynb @@ -149,7 +149,7 @@ " lib_name:str=None, # Package name, defaults to local repo folder name\n", " branch='master', # Repo default branch\n", " git_url='https://github.com/%(user)s/%(lib_name)s', # Repo URL\n", - " custom_sidebar:bool_arg=False, # Create custom sidebar?\n", + " custom_sidebar:bool_arg=False, # Use a custom sidebar.yml?\n", " nbs_path='.', # Path to notebooks\n", " lib_path='%(lib_name)s', # Path to package root\n", " doc_path='_docs', # Path to rendered docs\n", @@ -172,6 +172,7 @@ " allowed_cell_metadata_keys='', # Preserve the list of keys in cell level metadata\n", " jupyter_hooks=True, # Run Jupyter hooks?\n", " clean_ids=True, # Remove ids from plaintext reprs?\n", + " custom_quarto_yml=False, # Use a custom _quarto.yml?\n", "):\n", " \"Apply default settings where missing in `cfg`\"\n", " if lib_name is None:\n", @@ -302,7 +303,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "{'lib_name': 'T', 'branch': 'master', 'git_url': 'https://github.com/%(user)s/%(lib_name)s', 'custom_sidebar': 'False', 'nbs_path': '.', 'lib_path': '%(lib_name)s', 'doc_path': '_docs', 'tst_flags': '', 'version': '0.0.1', 'doc_host': 'https://%(user)s.github.io', 'doc_baseurl': '/%(lib_name)s', 'keywords': 'nbdev jupyter notebook python', 'license': 'apache2', 'copyright': 'None', 'status': '3', 'min_python': '3.7', 'audience': 'Developers', 'language': 'English', 'recursive': 'False', 'black_formatting': 'False', 'readme_nb': 'index.ipynb', 'title': '%(lib_name)s', 'allowed_metadata_keys': '', 'allowed_cell_metadata_keys': ''}\n" + "{'lib_name': 'T', 'branch': 'master', 'git_url': 'https://github.com/%(user)s/%(lib_name)s', 'custom_sidebar': 'False', 'nbs_path': '.', 'lib_path': '%(lib_name)s', 'doc_path': '_docs', 'tst_flags': '', 'version': '0.0.1', 'doc_host': 'https://%(user)s.github.io', 'doc_baseurl': '/%(lib_name)s', 'keywords': 'nbdev jupyter notebook python', 'license': 'apache2', 'copyright': 'None', 'status': '3', 'min_python': '3.7', 'audience': 'Developers', 'language': 'English', 'recursive': 'False', 'black_formatting': 'False', 'readme_nb': 'index.ipynb', 'title': '%(lib_name)s', 'allowed_metadata_keys': '', 'allowed_cell_metadata_keys': '', 'jupyter_hooks': 'True', 'clean_ids': 'True', 'custom_quarto_yml': 'False'}\n" ] } ], @@ -321,13 +322,9 @@ "source": [ "#|export\n", "def config_key(c, default=None, path=True, missing_ok=None):\n", - " \"Look for key `c` in settings.ini and fail gracefully if not found and no default provided\"\n", - " if missing_ok is not None:\n", - " warn(\"`missing_ok` is no longer used. Don't pass it to `config_key` to silence this warning.\")\n", - " cfg = get_config()\n", - " res = cfg.path(c, default) if path else cfg.get(c, default)\n", - " if res is None: raise ValueError(f'`{c}` not specified in {_nbdev_config_name}')\n", - " return res" + " \"Deprecated: use `get_config().get` or `get_config().path` instead.\"\n", + " warn(\"`config_key` is deprecated. Use `get_config().get` or `get_config().path` instead.\", DeprecationWarning)\n", + " return get_config().path(c, default) if path else get_config().get(c, default)" ] }, { @@ -336,17 +333,18 @@ "metadata": {}, "outputs": [ { - "name": "stdout", + "name": "stderr", "output_type": "stream", "text": [ - "T\n" + "/var/folders/ft/0gnvc3ts5jz4ddqtttp6tjvm0000gn/T/ipykernel_5473/2105843470.py:4: DeprecationWarning: `config_key` is deprecated. Use `get_config().get` or `get_config().path` instead.\n", + " warn(\"`config_key` is deprecated. Use `get_config().get` or `get_config().path` instead.\", DeprecationWarning)\n" ] } ], "source": [ "#|hide\n", "# `config_key` returns defaults if no config file exists\n", - "with tempfile.TemporaryDirectory() as d, working_directory(d): print(config_key('lib_path', path=False))\n", + "with tempfile.TemporaryDirectory() as d, working_directory(d): assert config_key('lib_path', path=False) in ('T','tmp')\n", "get_config.cache_clear()" ] }, @@ -432,7 +430,7 @@ "#|export\n", "def basic_export_nb(fname, name, dest=None):\n", " \"Basic exporter to bootstrap nbdev\"\n", - " if dest is None: dest = config_key('lib_path')\n", + " if dest is None: dest = get_config().path('lib_path')\n", " fname,dest = Path(fname),Path(dest)\n", " nb = read_nb(fname)\n", "\n", diff --git a/nbs/04b_doclinks.ipynb b/nbs/04b_doclinks.ipynb index 7ec9fa679..efa4256e9 100644 --- a/nbs/04b_doclinks.ipynb +++ b/nbs/04b_doclinks.ipynb @@ -392,10 +392,10 @@ "#|export\n", "def build_modidx():\n", " \"Create _modidx.py\"\n", - " dest = config_key('lib_path')\n", + " dest = get_config().path('lib_path')\n", " if os.environ.get('IN_TEST',0): return\n", " _fn = dest/'_modidx.py'\n", - " nbs_path = config_key('nbs_path')\n", + " nbs_path = get_config().path('nbs_path')\n", " with contextlib.suppress(FileNotFoundError): _fn.unlink()\n", " cfg = get_config()\n", " doc_func = partial(_doc_link, urljoin(cfg.doc_host,cfg.doc_baseurl))\n", @@ -413,9 +413,9 @@ "@delegates(globtastic, but=['file_glob', 'skip_folder_re'])\n", "def nbglob(path=None, skip_folder_re = '^[_.]', file_glob='*.ipynb', recursive=True, key='nbs_path',\n", " as_path=False, **kwargs):\n", - " \"Find all files in a directory matching an extension given a `config_key`.\"\n", - " path = Path(path or config_key(key))\n", - " if recursive is None: recursive=str2bool(config_key('recursive', path=False))\n", + " \"Find all files in a directory matching an extension given a config key.\"\n", + " path = Path(path or get_config().path(key))\n", + " if recursive is None: recursive=str2bool(get_config().recursive)\n", " res = globtastic(path, file_glob=file_glob, skip_folder_re=skip_folder_re, **kwargs)\n", " return res.map(Path) if as_path else res" ] diff --git a/nbs/10_cli.ipynb b/nbs/10_cli.ipynb index 225fcbe68..87799cd35 100644 --- a/nbs/10_cli.ipynb +++ b/nbs/10_cli.ipynb @@ -73,7 +73,7 @@ " except:\n", " warnings.warn('Please install ghp-import with `pip install ghp-import`')\n", " return\n", - " ghp_import(config_key('doc_path'), push=True, stderr=True, no_history=True)" + " ghp_import(get_config().path('doc_path'), push=True, stderr=True, no_history=True)" ] }, { @@ -116,8 +116,8 @@ " returnit:bool=False # Return list of files found\n", "):\n", " \"Create sidebar.yml\"\n", - " if not force and str2bool(config_key('custom_sidebar', path=False)): return\n", - " path = config_key(\"nbs_path\") if not path else Path(path)\n", + " if not force and str2bool(get_config().custom_sidebar): return\n", + " path = get_config().path('nbs_path') if not path else Path(path)\n", " files = nbglob(path, func=_f, symlinks=symlinks, file_re=file_re, folder_re=folder_re, file_glob=file_glob,\n", " skip_file_glob=skip_file_glob, skip_file_re=skip_file_re, skip_folder_re=skip_folder_re).sorted(key=_sort)\n", " lastd,res = Path(),[]\n", @@ -470,7 +470,7 @@ " p = cfg.path('nbs_path')/'_quarto.yml'\n", " vals = {k:cfg.get(k) for k in ['doc_path', 'title', 'description', 'branch', 'git_url', 'doc_host', 'doc_baseurl']}\n", " # Do not build _quarto_yml if custom_quarto_yml is set to True\n", - " if str2bool(config_key('custom_quarto_yml', default=\"False\", path=False)): return\n", + " if str2bool(get_config().custom_quarto_yml): return\n", " if 'title' not in vals: vals['title'] = vals['lib_name']\n", " yml=_quarto_yml.format(**vals)\n", " p.write_text(yml)" @@ -549,8 +549,8 @@ "def _doc_paths(path:str=None, doc_path:str=None):\n", " cfg = get_config()\n", " cfg_path = cfg.config_path\n", - " path = config_key(\"nbs_path\") if not path else Path(path)\n", - " doc_path = config_key(\"doc_path\") if not doc_path else Path(doc_path)\n", + " path = cfg.path('nbs_path') if not path else Path(path)\n", + " doc_path = cfg.path('doc_path') if not doc_path else Path(doc_path)\n", " tmp_doc_path = path/f\"{cfg['doc_path']}\"\n", " return cfg,cfg_path,path,doc_path,tmp_doc_path" ] @@ -564,7 +564,7 @@ "source": [ "#|export\n", "def _render_readme(path):\n", - " idx_path = path/config_key('readme_nb', path=False)\n", + " idx_path = path/get_config().readme_nb\n", " if not idx_path.exists(): return\n", "\n", " yml_path = path/'sidebar.yml'\n", diff --git a/nbs/11_clean.ipynb b/nbs/11_clean.ipynb index 36cb284ec..343138d57 100644 --- a/nbs/11_clean.ipynb +++ b/nbs/11_clean.ipynb @@ -87,7 +87,7 @@ " warnings.warn(\"Please install jupyter and try again\")\n", " return\n", "\n", - " fname = Path(fname if fname else config_key(\"nbs_path\"))\n", + " fname = Path(fname if fname else get_config().path('nbs_path'))\n", " path = fname if fname.is_dir() else fname.parent\n", " check_fname = path/\".last_checked\"\n", " last_checked = os.path.getmtime(check_fname) if check_fname.exists() else None\n", @@ -377,7 +377,7 @@ " _write = partial(process_write, warn_msg='Failed to clean notebook', proc_nb=_clean)\n", " if stdin: return _write(f_in=sys.stdin, f_out=sys.stdout)\n", " \n", - " if fname is None: fname = config_key(\"nbs_path\")\n", + " if fname is None: fname = get_config().path('nbs_path')\n", " for f in globtastic(fname, file_glob='*.ipynb', skip_folder_re='^[_.]'): _write(f_in=f, disp=disp)" ] }, diff --git a/nbs/14_test.ipynb b/nbs/14_test.ipynb index 074214daa..e6d89178f 100644 --- a/nbs/14_test.ipynb +++ b/nbs/14_test.ipynb @@ -188,7 +188,7 @@ " ignore_fname:str='.notest' # Filename that will result in siblings being ignored\n", "):\n", " \"Test in parallel notebooks matching `fname`, passing along `flags`\"\n", - " skip_flags = config_key('tst_flags', path=False).split()\n", + " skip_flags = get_config().tst_flags.split()\n", " force_flags = flags.split()\n", " files = nbglob(fname, recursive=recursive, file_re=file_re, folder_re=folder_re,\n", " skip_file_glob=skip_file_glob, skip_file_re=skip_file_re, as_path=True, symlinks=symlinks)\n", @@ -196,7 +196,7 @@ " if len(files)==0: return print('No files were eligible for testing')\n", "\n", " if n_workers is None: n_workers = 0 if len(files)==1 else min(num_cpus(), 8)\n", - " os.chdir(config_key(\"nbs_path\"))\n", + " os.chdir(get_config().path('nbs_path'))\n", " if IN_NOTEBOOK: kwargs = {'method':'spawn'} if os.name=='nt' else {'method':'forkserver'}\n", " else: kwargs = {}\n", " results = parallel(test_nb, files, skip_flags=skip_flags, force_flags=force_flags, n_workers=n_workers,\n", diff --git a/nbs/15_migrate.ipynb b/nbs/15_migrate.ipynb index 1248e9636..995b114e0 100644 --- a/nbs/15_migrate.ipynb +++ b/nbs/15_migrate.ipynb @@ -29,7 +29,7 @@ "#|export\n", "from nbdev.process import first_code_ln\n", "from nbdev.processors import nb_fmdict, construct_fm, insert_frontmatter, is_frontmatter, yml2dict, filter_fm\n", - "from nbdev.read import read_nb, config_key\n", + "from nbdev.read import get_config, read_nb\n", "from nbdev.sync import write_nb\n", "from nbdev.clean import process_write\n", "from nbdev.showdoc import show_doc\n", @@ -425,7 +425,7 @@ "def _re_v1():\n", " d = ['default_exp', 'export', 'exports', 'exporti', 'hide', 'hide_input', 'collapse_show', 'collapse',\n", " 'collapse_hide', 'collapse_input', 'hide_output', 'default_cls_lvl']\n", - " d += L(config_key('tst_flags', path=False)).filter()\n", + " d += L(get_config().tst_flags).filter()\n", " d += [s.replace('_', '-') for s in d] # allow for hyphenated version of old directives\n", " _tmp = '|'.join(list(set(d)))\n", " return re.compile(f\"^[ \\f\\v\\t]*?(#)\\s*({_tmp})(?!\\S)\", re.MULTILINE)\n", @@ -730,7 +730,7 @@ " _write = partial(process_write, warn_msg='Failed to replace directives', proc_nb=_migrate)\n", " if stdin: _write(f_in=sys.stdin, f_out=sys.stdout)\n", " _skip_re = None if no_skip else '^[_.]'\n", - " if fname is None: fname = config_key(\"nbs_path\")\n", + " if fname is None: fname = get_config().path('nbs_path')\n", " for f in globtastic(fname, file_glob='*.ipynb', skip_folder_re=_skip_re): _write(f_in=f, disp=disp)" ] }, diff --git a/nbs/17_release.ipynb b/nbs/17_release.ipynb index a30c9453f..7bcd838f1 100644 --- a/nbs/17_release.ipynb +++ b/nbs/17_release.ipynb @@ -631,7 +631,7 @@ " upload_user:str=None # Optional user to upload package to\n", "):\n", " \"Create a `meta.yaml` file ready to be built into a package, and optionally build and upload it\"\n", - " name = config_key('lib_name', path=False)\n", + " name = get_config().lib_name\n", " write_conda_meta(path)\n", " out = f\"Done. Next steps:\\n```\\ncd {path}\\n\"\"\"\n", " os.chdir(path)\n", @@ -643,7 +643,7 @@ " print(f\"conda {build} --no-anaconda-upload {build_args} {name}\")\n", " res = _run(f\"conda {build} --no-anaconda-upload {build_args} {name}\")\n", " if skip_upload: return\n", - " if not upload_user: upload_user = config_key('conda_user', path=False)\n", + " if not upload_user: upload_user = get_config().conda_user\n", " if not upload_user: return print(\"`conda_user` not in settings.ini and no `upload_user` passed. Cannot upload\")\n", " if 'anaconda upload' not in res: return print(f\"{res}\\n\\Failed. Check auto-upload not set in .condarc. Try `--do_build False`.\")\n", " return anaconda_upload(name, loc)" @@ -704,7 +704,7 @@ " repository:str=\"pypi\" # Respository to upload to (defined in ~/.pypirc)\n", "):\n", " \"Create and upload Python package to PyPI\"\n", - " _dir = config_key(\"lib_path\").parent\n", + " _dir = get_config().path('lib_path').parent\n", " system(f'cd {_dir} && rm -rf dist && python setup.py sdist bdist_wheel')\n", " system(f'twine upload --repository {repository} {_dir}/dist/*')" ] diff --git a/settings.ini b/settings.ini index 4c18a692d..c973ec992 100644 --- a/settings.ini +++ b/settings.ini @@ -64,4 +64,5 @@ allowed_metadata_keys = allowed_cell_metadata_keys = jupyter_hooks = True clean_ids = True +custom_quarto_yml = False