Repository: RasaHQ/rasa
Pull request: rasa train core: use additional training arguments
**Proposed changes**:
- Pass additional arguments, such as `augmentation` to train methods.

closes #3274 

**Status (please check what you already did)**:
- [x] made PR ready for code review
- [ ] added some tests for the functionality
- [ ] updated the documentation
- [x] updated the changelog
- [x] reformat files using `black` (please check [Readme](https://github.com/RasaHQ/rasa_nlu#code-style) for instructions)


Problem statement:
`rasa train core --augmentation 0` doesn't work
<!-- THIS INFORMATION IS MANDATORY - YOUR ISSUE WILL BE CLOSED IF IT IS MISSING. If you don't know your Rasa Core version, use `pip list | grep rasa`. Removing the below information is allowed for FEATURE REQUESTS. --> 

**Rasa version**: `master`

**Python version**: `3.7`

**Operating system** (windows, osx, ...): `osx`

**Issue**:
setting augmentation to `0` with `rasa train core --augmentation 0` doesn't work

Hints from issue discussion:
we should also check the other kwargs which can be passed to the rasa core train command

Commit message: Add changelog entry.

Patch to review:
diff --git a/.travis.yml b/.travis.yml
index 374575bd517c..c4e060d2dcbe 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,7 +18,7 @@ install:
   - python -m pip install -U pip
   - pip install git+https://github.com/tmbo/MITIE.git
   - pip install -r requirements-dev.txt
-  - pip install -e .
+  - pip install -e . --no-use-pep517
   - pip install coveralls==1.3.0
   - pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_md-2.0.0/en_core_web_md-2.0.0.tar.gz --no-cache-dir > jnk
   - python -m spacy link en_core_web_md en
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 48734edb1917..d60fd982068f 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -55,3 +55,4 @@ Fixed
   Store
 - ``rasa nlu test`` doesn't error anymore when a test file is passed with ``-u``
 - in interactive learning: only updates entity values if user changes annotation
+- ``rasa train core`` actually uses additional arguments, such as `augmentation`
\ No newline at end of file
diff --git a/rasa/cli/train.py b/rasa/cli/train.py
index c010128f51ff..3be0f3c8b220 100644
--- a/rasa/cli/train.py
+++ b/rasa/cli/train.py
@@ -118,7 +118,14 @@ def train(args: argparse.Namespace) -> Optional[Text]:
         get_validated_path(f, "data", DEFAULT_DATA_PATH) for f in args.data
     ]
 
-    return rasa.train(domain, config, training_files, args.out, args.force)
+    return rasa.train(
+        domain,
+        config,
+        training_files,
+        args.out,
+        args.force,
+        extract_additional_arguments(args),
+    )
 
 
 def train_core(
@@ -143,7 +150,14 @@ def train_core(
 
         config = get_validated_path(args.config, "config", DEFAULT_CONFIG_PATH)
 
-        return train_core(args.domain, config, stories, output, train_path)
+        return train_core(
+            args.domain,
+            config,
+            stories,
+            output,
+            train_path,
+            extract_additional_arguments(args),
+        )
     else:
         from rasa.core.train import do_compare_training
 
@@ -162,3 +176,13 @@ def train_nlu(
     nlu_data = get_validated_path(args.nlu, "nlu", DEFAULT_DATA_PATH)
 
     return train_nlu(config, nlu_data, output, train_path)
+
+
+def extract_additional_arguments(args: argparse.Namespace) -> typing.Dict:
+    return {
+        "augmentation_factor": args.augmentation,
+        "dump_stories": args.dump_stories,
+        "debug_plots": args.debug_plots,
+        "percentages": args.percentages,
+        "runs": args.runs,
+    }
diff --git a/rasa/train.py b/rasa/train.py
index e2b08cb32a9a..08994e0f8b8e 100644
--- a/rasa/train.py
+++ b/rasa/train.py
@@ -2,7 +2,7 @@
 import os
 import tempfile
 import typing
-from typing import Text, Optional, List, Union
+from typing import Text, Optional, List, Union, Dict
 
 from rasa import model, data
 from rasa.cli.utils import create_output_path, print_success
@@ -18,10 +18,11 @@ def train(
     training_files: Union[Text, List[Text]],
     output: Text = DEFAULT_MODELS_PATH,
     force_training: bool = False,
+    args: Optional[Dict] = None,
 ) -> Optional[Text]:
     loop = asyncio.get_event_loop()
     return loop.run_until_complete(
-        train_async(domain, config, training_files, output, force_training)
+        train_async(domain, config, training_files, output, force_training, args)
     )
 
 
@@ -31,6 +32,7 @@ async def train_async(
     training_files: Union[Text, List[Text]],
     output: Text = DEFAULT_MODELS_PATH,
     force_training: bool = False,
+    args: Optional[Dict] = None,
 ) -> Optional[Text]:
     """Trains a Rasa model (Core and NLU).
 
@@ -40,6 +42,7 @@ async def train_async(
         training_files: Paths to the training data for Core and NLU.
         output: Output path.
         force_training: If `True` retrain model even if data has not changed.
+        args: Additional training parameters.
 
     Returns:
         Path of the trained model archive.
@@ -68,7 +71,9 @@ async def train_async(
             retrain_nlu = not model.merge_model(old_nlu, target_path)
 
     if force_training or retrain_core:
-        await train_core_async(domain, config, story_directory, output, train_path)
+        await train_core_async(
+            domain, config, story_directory, output, train_path, args
+        )
     else:
         print (
             "Dialogue data / configuration did not change. "
@@ -99,16 +104,26 @@ async def train_async(
 
 
 def train_core(
-    domain: Text, config: Text, stories: Text, output: Text, train_path: Optional[Text]
+    domain: Text,
+    config: Text,
+    stories: Text,
+    output: Text,
+    train_path: Optional[Text],
+    args: Optional[Dict],
 ) -> Optional[Text]:
     loop = asyncio.get_event_loop()
     return loop.run_until_complete(
-        train_core_async(domain, config, stories, output, train_path)
+        train_core_async(domain, config, stories, output, train_path, args)
     )
 
 
 async def train_core_async(
-    domain: Text, config: Text, stories: Text, output: Text, train_path: Optional[Text]
+    domain: Text,
+    config: Text,
+    stories: Text,
+    output: Text,
+    train_path: Optional[Text] = None,
+    args: Optional[Dict] = None,
 ) -> Optional[Text]:
     """Trains a Core model.
 
@@ -119,6 +134,7 @@ async def train_core_async(
         output: Output path.
         train_path: If `None` the model will be trained in a temporary
             directory, otherwise in the provided directory.
+        args: Additional training parameters.
 
     Returns:
         If `train_path` is given it returns the path to the model archive,
@@ -135,6 +151,7 @@ async def train_core_async(
         stories_file=stories,
         output_path=os.path.join(_train_path, "core"),
         policy_config=config,
+        kwargs=args,
     )
 
     if not train_path:


Code review comments:
diff_hunk: @@ -99,16 +104,26 @@ def train(
 
 
 def train_core(
-    domain: Text, config: Text, stories: Text, output: Text, train_path: Optional[Text]
+    domain: Text,
+    config: Text,
+    stories: Text,
+    output: Text,
+    train_path: Optional[Text],
+    args: Optional[Dict],
 ) -> Optional[Text]:
     loop = asyncio.get_event_loop()
     return loop.run_until_complete(
-        train_core_async(domain, config, stories, output, train_path)
+        train_core_async(domain, config, stories, output, train_path, args)
     )
 
 
 async def train_core_async(
-    domain: Text, config: Text, stories: Text, output: Text, train_path: Optional[Text]
+    domain: Text,
+    config: Text,
+    stories: Text,
+    output: Text,
+    train_path: Optional[Text] = None,
+    args: Optional[Dict] = None,
path: rasa/train.py
text: @user1:
why don't we name it `kwargs`?
also on unrelated note, why in `agent.train` it is `**kwargs` while in `rasa.core.train` it is `kwargs`?

@author:
will rename it

Regarding your question: Is just the way how it is implemented. The `**` operator "unpacks" the keyword arguments. We could also use a `Dict` as in `rasa.core.train`. No major difference.