Skip to content

Commit d480fb0

Browse files
committed
CHANGELOG
1 parent 5e35866 commit d480fb0

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,19 @@
22

33
<!-- do not remove -->
44

5+
## 1.0.10
6+
7+
### Breaking Changes
8+
9+
- remove `parallel_chunked`, use `chunksize` arg to `parallel` instead ([#81](https://api.github.com/repos/fastai/fastcore/issues/81))
10+
11+
### New Features
12+
13+
- move fastscript to fastcore.script ([#84](https://api.github.com/repos/fastai/fastcore/issues/84))
14+
- add `run_proc` and `do_request` ([#83](https://api.github.com/repos/fastai/fastcore/issues/83))
15+
- added `chunksize` to `parallel`, which passes to `ProcessPoolExecutor.map` ([#82](https://api.github.com/repos/fastai/fastcore/issues/82))
16+
- move metaclasses and delegates et al to new `meta` module ([#80](https://api.github.com/repos/fastai/fastcore/issues/80))
17+
518
## 1.0.4
619

720
### New Features

nbs/07_script.ipynb

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"cell_type": "markdown",
1515
"metadata": {},
1616
"source": [
17-
"# fastscript\n",
17+
"# Script - command line interfaces\n",
1818
"\n",
1919
"> A fast way to turn your python function into a script."
2020
]
@@ -26,20 +26,6 @@
2626
"Part of [fast.ai](https://www.fast.ai)'s toolkit for delightful developer experiences."
2727
]
2828
},
29-
{
30-
"cell_type": "markdown",
31-
"metadata": {},
32-
"source": [
33-
"## Install"
34-
]
35-
},
36-
{
37-
"cell_type": "markdown",
38-
"metadata": {},
39-
"source": [
40-
"Either `pip install fastscript` or `conda install -c fastai fastscript`"
41-
]
42-
},
4329
{
4430
"cell_type": "markdown",
4531
"metadata": {},
@@ -53,9 +39,9 @@
5339
"source": [
5440
"Sometimes, you want to create a quick script, either for yourself, or for others. But in Python, that involves a whole lot of boilerplate and ceremony, especially if you want to support command line arguments, provide help, and other niceties. You can use [argparse](https://docs.python.org/3/library/argparse.html) for this purpose, which comes with Python, but it's complex and verbose.\n",
5541
"\n",
56-
"`fastscript` makes life easier. There are much fancier modules to help you write scripts (we recommend [Python Fire](https://github.com/google/python-fire), and [Click](https://click.palletsprojects.com/en/7.x/) is also popular), but fastscript is very fast and very simple. In fact, it's <50 lines of code! Basically, it's just a little wrapper around `argparse` that uses modern Python features and some thoughtful defaults to get rid of the boilerplate.\n",
42+
"`fastcore.script` makes life easier. There are much fancier modules to help you write scripts (we recommend [Python Fire](https://github.com/google/python-fire), and [Click](https://click.palletsprojects.com/en/7.x/) is also popular), but fastcore.script is very fast and very simple. In fact, it's <50 lines of code! Basically, it's just a little wrapper around `argparse` that uses modern Python features and some thoughtful defaults to get rid of the boilerplate.\n",
5743
"\n",
58-
"For full details, see the [docs](https://fastscript.fast.ai) for `core`."
44+
"For full details, see the [docs](https://fastcore.script.fast.ai) for `core`."
5945
]
6046
},
6147
{
@@ -72,7 +58,7 @@
7258
"Here's a complete example:\n",
7359
"\n",
7460
"```python\n",
75-
"from fastscript import *\n",
61+
"from fastcore.script import *\n",
7662
"@call_parse\n",
7763
"def main(msg:Param(\"The message\", str),\n",
7864
" upper:Param(\"Convert to uppercase?\", bool_arg)=False):\n",
@@ -82,9 +68,9 @@
8268
"If you copy that info a file and run it, you'll see:\n",
8369
"\n",
8470
"```\n",
85-
"$ python examples/test_fastscript.py\n",
86-
"usage: test_fastscript.py [-h] [--upper UPPER] msg\n",
87-
"test_fastscript.py: error: the following arguments are required: msg\n",
71+
"$ python test_fastcore.script.py\n",
72+
"usage: test_fastcore.script.py [-h] [--upper UPPER] msg\n",
73+
"test_fastcore.script.py: error: the following arguments are required: msg\n",
8874
"```\n",
8975
"\n",
9076
"As you see, we didn't need any `if __name__ == \"__main__\"`, we didn't have to parse arguments, we just wrote a function, added a decorator to it, and added some annotations to our function's parameters. As a bonus, we can also use this function directly from a REPL such as Jupyter Notebook - it's not just for command line scripts!"
@@ -101,7 +87,7 @@
10187
"cell_type": "markdown",
10288
"metadata": {},
10389
"source": [
104-
"Each parameter in your function should have an annotation `Param(...)` (as in the example above). You can pass the following when calling `Param`: `help`,`type`,`opt`,`action`,`nargs`,`const`,`choices`,`required` . Except for `opt`, all of these are just passed directly to `argparse`, so you have all the power of that module at your disposal. Generally you'll want to pass at least `help` (since this is provided as the help string for that parameter) and `type` (to ensure that you get the type of data you expect). `opt` is a bool that defines whether a param is optional or required (positional) - but you'll generally not need to set this manually, because fastscript will set it for you automatically based on *default* values.\n",
90+
"Each parameter in your function should have an annotation `Param(...)` (as in the example above). You can pass the following when calling `Param`: `help`,`type`,`opt`,`action`,`nargs`,`const`,`choices`,`required` . Except for `opt`, all of these are just passed directly to `argparse`, so you have all the power of that module at your disposal. Generally you'll want to pass at least `help` (since this is provided as the help string for that parameter) and `type` (to ensure that you get the type of data you expect). `opt` is a bool that defines whether a param is optional or required (positional) - but you'll generally not need to set this manually, because fastcore.script will set it for you automatically based on *default* values.\n",
10591
"\n",
10692
"You should provide a default (after the `=`) for any *optional* parameters. If you don't provide a default for a parameter, then it will be a *positional* parameter."
10793
]
@@ -117,7 +103,7 @@
117103
"cell_type": "markdown",
118104
"metadata": {},
119105
"source": [
120-
"There's a really nice feature of pip/setuptools that lets you create commandline scripts directly from functions, makes them available in the `PATH`, and even makes your scripts cross-platform (e.g. in Windows it creates an exe). fastscript supports this feature too. To use it, follow [this example](fastscript/test_cli.py) from `fastscript/test_cli.py` in the repo. As you see, it's basically identical to the script example above, except that we can treat it as a module. The trick to making this available as a script is to add a `console_scripts` section to your setup file, of the form: `script_name=module:function_name`. E.g. in this case we use: `test_fastscript=fastscript.test_cli:main`. With this, you can then just type `test_fastscript` at any time, from any directory, and your script will be called (once it's installed using one of the methods below).\n",
106+
"There's a really nice feature of pip/setuptools that lets you create commandline scripts directly from functions, makes them available in the `PATH`, and even makes your scripts cross-platform (e.g. in Windows it creates an exe). fastcore.script supports this feature too. The trick to making a function available as a script is to add a `console_scripts` section to your setup file, of the form: `script_name=module:function_name`. E.g. in this case we use: `test_fastcore.script=fastcore.script.test_cli:main`. With this, you can then just type `test_fastcore.script` at any time, from any directory, and your script will be called (once it's installed using one of the methods below).\n",
121107
"\n",
122108
"You don't actually have to write a `setup.py` yourself. Instead, just use [nbdev](https://nbdev.fast.ai). Then modify `settings.ini` as appropriate for your module/script. To install your script directly, you can type `pip install -e .`. Your script, when installed this way (it's called an [editable install](http://codumentary.blogspot.com/2014/11/python-tip-of-year-pip-install-editable.html), will automatically be up to date even if you edit it - there's no need to reinstall it after editing. With nbdev you can even make your module and script available for installation directly from pip and conda by running `make release`."
123109
]
@@ -182,7 +168,7 @@
182168
"source": [
183169
"Each parameter in your function should have an annotation `Param(...)`. You can pass the following when calling `Param`: `help`,`type`,`opt`,`action`,`nargs`,`const`,`choices`,`required` (i.e. it takes the same parameters as `argparse.ArgumentParser.add_argument`, plus `opt`). Except for `opt`, all of these are just passed directly to `argparse`, so you have all the power of that module at your disposal. Generally you'll want to pass at least `help` (since this is provided as the help string for that parameter) and `type` (to ensure that you get the type of data you expect).\n",
184170
"\n",
185-
"`opt` is a bool that defines whether a param is optional or required (positional) - but you'll generally not need to set this manually, because fastscript will set it for you automatically based on *default* values. You should provide a default (after the `=`) for any *optional* parameters. If you don't provide a default for a parameter, then it will be a *positional* parameter."
171+
"`opt` is a bool that defines whether a param is optional or required (positional) - but you'll generally not need to set this manually, because fastcore.script will set it for you automatically based on *default* values. You should provide a default (after the `=`) for any *optional* parameters. If you don't provide a default for a parameter, then it will be a *positional* parameter."
186172
]
187173
},
188174
{
@@ -380,15 +366,15 @@
380366
"metadata": {},
381367
"outputs": [],
382368
"source": [
383-
"test_eq(os.system('test_fastscript \"Test if this still works\"'), 0)\n",
369+
"test_eq(os.system('test_fastcore.script \"Test if this still works\"'), 0)\n",
384370
"test_eq(test_add(1,2), 3)"
385371
]
386372
},
387373
{
388374
"cell_type": "markdown",
389375
"metadata": {},
390376
"source": [
391-
"This is the main way to use `fastscript`; decorate your function with `call_parse`, add `Param` annotations as shown above, and it can then be used as a script."
377+
"This is the main way to use `fastcore.script`; decorate your function with `call_parse`, add `Param` annotations as shown above, and it can then be used as a script."
392378
]
393379
},
394380
{

0 commit comments

Comments
 (0)