Repository: mlflow/mlflow

Issue:
[FR] Add Fastai model flavor example code in the MLflow examples 
Thank you for submitting a feature request. **Before proceeding, please review MLflow's [Issue Policy for feature requests](https://www.github.com/mlflow/mlflow/blob/master/ISSUE_POLICY.md#feature-requests) and the [MLflow Contributing Guide](https://github.com/mlflow/mlflow/blob/master/CONTRIBUTING.rst)**.

**Please fill in this feature request template to ensure a timely and thorough response.**

## Willingness to contribute
The MLflow Community encourages new feature contributions. Would you or another member of your organization be willing to contribute an implementation of this feature (either as an MLflow Plugin or an enhancement to the MLflow codebase)?

- [x] Yes. I can contribute this feature independently.
- [ ] Yes. I would be willing to contribute this feature with guidance from the MLflow community.
- [ ] No. I cannot contribute this feature at this time.

## Proposal Summary

(In a few sentences, provide a clear, high-level description of the feature request)

## Motivation
- What is the use case for this feature?

This adds to our examples of tutorials, MLflavor models and MLprojects learning assets

- Why is this use case valuable to support for MLflow users in general?

MLflow supports this flavor

- Why is this use case valuable to support for your project(s) or organization?

Fastai is gaining popularity and showing its built-in integration with MLflow is as important as all other ML model flavors we support


### What component(s), interfaces, languages, and integrations does this feature affect?
Components 
- [ ] `area/artifacts`: Artifact stores and artifact logging
- [ ] `area/build`: Build and test infrastructure for MLflow
- [ ] `area/docs`: MLflow documentation pages
- [x] `area/examples`: Example code
- [ ] `area/model-registry`: Model Registry service, APIs, and the fluent client calls for
Model Registry
- [x] `area/models`: MLmodel format, model serialization/deserialization, flavors
- [ ] `area/projects`: MLproject format, project running backends
- [ ] `area/scoring`: Local serving, model deployment tools, spark UDFs
- [ ] `area/tracking`: Tracking Service, tracking client APIs, autologging

Interfaces
- [ ] `area/uiux`: Front-end, user experience, JavaScript, plotting
- [ ] `area/docker`: Docker use across MLflow's components, such as MLflow Projects and MLflow Models
- [ ] `area/sqlalchemy`: Use of SQLAlchemy in the Tracking Service or Model Registry
- [ ] `area/windows`: Windows support

Languages 
- [ ] `language/r`: R APIs and clients
- [ ] `language/java`: Java APIs and clients

Integrations
- [ ] `integrations/azure`: Azure and Azure ML integrations
- [ ] `integrations/sagemaker`: SageMaker integrations

## Details

We have myriad examples of the ML model flavors in the `mlflow/examples` directory for developers to learn and try. Since we added  `fastai` model flavor, having an example of how to use it helps the developers who are getting started.

I propose to add the following to the examples' codebase:

-  A new fastai example that showcases autologging

-  a README.md that describes the model training and how to run and use it

-  Additional files—MLproject and conda.yaml— to make it runnable as an MLproject





Discussion:

Resolving patch:
diff --git a/examples/fastai/train.py b/examples/fastai/train.py
new file mode 100644
--- /dev/null
+++ b/examples/fastai/train.py
@@ -0,0 +1,41 @@
+#
+# This short example is based on the fastai GitHub Repository of vision examples
+# https://github.com/fastai/fastai/blob/master/examples/vision.ipynb
+# Modified here to show mlflow.fastai.autolog() capabilities
+#
+import argparse
+import fastai.vision as vis
+import mlflow.fastai
+
+def parse_args():
+    parser = argparse.ArgumentParser(description='Fastai example')
+    parser.add_argument('--lr', type=float, default=0.01,
+                       help='learning rate to update step size at each step (default: 0.01)')
+    parser.add_argument('--epochs', type=int, default=5,
+                       help='number of epochs (default: 5). Note it takes about 1 min per epoch')
+    return parser.parse_args()
+
+def main():
+    # Parse command-line arguments
+    args = parse_args()
+
+    # Download and untar the MNIST data set
+    path = vis.untar_data(vis.URLs.MNIST_SAMPLE)
+
+    # Prepare, transform, and normalize the data
+    data = vis.ImageDataBunch.from_folder(path, ds_tfms=(vis.rand_pad(2, 28), []), bs=64)
+    data.normalize(vis.imagenet_stats)
+
+    # Train and fit the Learner model
+    learn = vis.cnn_learner(data, vis.models.resnet18, metrics=vis.accuracy)
+
+    # Enable auto logging
+    mlflow.fastai.autolog()
+
+    # Start MLflow session
+    with mlflow.start_run():
+        # Train and fit with default or supplied command line arguments
+        learn.fit(args.epochs, args.lr)
+
+if __name__ == '__main__':
+    main()


Test patch:
diff --git a/tests/examples/test_examples.py b/tests/examples/test_examples.py
--- a/tests/examples/test_examples.py
+++ b/tests/examples/test_examples.py
@@ -48,7 +48,8 @@ def replace_mlflow_with_dev_version(yml_path):
     (os.path.join('sklearn_elasticnet_diabetes', 'linux'), []),
     ('spacy', []),
     (os.path.join('tensorflow', 'tf1'), ['-P', 'steps=10']),
-    ('xgboost', ['-P', 'learning_rate=0.3', '-P', 'colsample_bytree=0.8', '-P', 'subsample=0.9'])
+    ('xgboost', ['-P', 'learning_rate=0.3', '-P', 'colsample_bytree=0.8', '-P', 'subsample=0.9']),
+    ('fastai', ['-P', 'lr=0.02', '-P', 'epochs=3']),
 ])
 def test_mlflow_run_example(directory, params, tmpdir):
     example_dir = os.path.join(EXAMPLES_DIR, directory)