diff --git a/.gitignore b/.gitignore index 0a78817..b2f5a41 100644 --- a/.gitignore +++ b/.gitignore @@ -65,4 +65,4 @@ dev.csv .venv/ model.h5 evaluation.png -mlruns/* \ No newline at end of file +mlruns* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index af2bfdd..44b6e75 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,4 +9,5 @@ RUN pip3 install -r requirements.txt COPY ["Zadanie 1.py", "."] COPY ["stats.py", "."] COPY ["train.py", "."] -COPY ["evaluate.py", "."] \ No newline at end of file +COPY ["evaluate.py", "."] +COPY ["MLProject", "."] \ No newline at end of file diff --git a/Jenkinsfile-train b/Jenkinsfile-train index 806437b..374f123 100644 --- a/Jenkinsfile-train +++ b/Jenkinsfile-train @@ -1,6 +1,6 @@ pipeline { agent { - docker { image 'adnovac/ium_s434760:1.2' } + docker { image 'adnovac/ium_s434760:3' } } parameters{ buildSelector( @@ -39,6 +39,7 @@ pipeline { stage('archive artifacts') { steps { archiveArtifacts 'model.h5' + archiveArtifacts 'fifa_overall/**/*' } } stage('send email') { diff --git a/MLProject b/MLProject index 94bf167..095b7e4 100644 --- a/MLProject +++ b/MLProject @@ -1,11 +1,11 @@ -name: Fifa Players +name: fifa_players + docker_env: - image: docker.io/adnovac/ium_s434760:2.0 + image: adnovac/ium_s434760 + entry_points: train: parameters: batch_size: {type: int, default: 15} epochs: {type: int, default: 16} - command: "python train.py {batch_size} {epochs}" - evaluate: - command: "python evaluate.py" \ No newline at end of file + command: "python3.8 train.py {batch_size} {epochs}" \ No newline at end of file diff --git a/fifa_overall/MLmodel b/fifa_overall/MLmodel new file mode 100644 index 0000000..43d82b6 --- /dev/null +++ b/fifa_overall/MLmodel @@ -0,0 +1,20 @@ +flavors: + keras: + data: data + keras_module: tensorflow.keras + keras_version: 2.4.0 + save_format: tf + python_function: + data: data + env: conda.yaml + loader_module: mlflow.keras + python_version: 3.8.10 +saved_input_example_info: + artifact_path: input_example.json + pandas_orient: split + type: dataframe +signature: + inputs: '[{"type": "tensor", "tensor-spec": {"dtype": "float64", "shape": [-1, 4]}}]' + outputs: '[{"type": "tensor", "tensor-spec": {"dtype": "float32", "shape": [-1, + 1]}}]' +utc_time_created: '2021-05-23 19:48:30.385262' diff --git a/fifa_overall/conda.yaml b/fifa_overall/conda.yaml new file mode 100644 index 0000000..e74efe0 --- /dev/null +++ b/fifa_overall/conda.yaml @@ -0,0 +1,10 @@ +channels: +- defaults +- conda-forge +dependencies: +- python=3.8.10 +- pip +- pip: + - mlflow + - tensorflow==2.4.1 +name: mlflow-env diff --git a/fifa_overall/data/model/saved_model.pb b/fifa_overall/data/model/saved_model.pb new file mode 100644 index 0000000..ce06b4c Binary files /dev/null and b/fifa_overall/data/model/saved_model.pb differ diff --git a/fifa_overall/data/model/variables/variables.data-00000-of-00001 b/fifa_overall/data/model/variables/variables.data-00000-of-00001 new file mode 100644 index 0000000..f3fe23c Binary files /dev/null and b/fifa_overall/data/model/variables/variables.data-00000-of-00001 differ diff --git a/fifa_overall/data/model/variables/variables.index b/fifa_overall/data/model/variables/variables.index new file mode 100644 index 0000000..09bbc9b Binary files /dev/null and b/fifa_overall/data/model/variables/variables.index differ diff --git a/fifa_overall/input_example.json b/fifa_overall/input_example.json new file mode 100644 index 0000000..6d340fe --- /dev/null +++ b/fifa_overall/input_example.json @@ -0,0 +1 @@ +{"columns": ["Age", "Nationality", "Position", "Club"], "data": [[0.38, 0.175, 1, 0.91846154]]} \ No newline at end of file diff --git a/train.py b/train.py index 4498904..f412579 100644 --- a/train.py +++ b/train.py @@ -37,5 +37,12 @@ history = model.fit( batch_size=batch_size, epochs=epochs, ) - -model.save(model_name) \ No newline at end of file +model.save(model_name) +signature = mlflow.models.signature.infer_signature(X, model.predict(X)) +input_example = { + "Age": 0.38, + "Nationality": 0.175, + "Position": 1, + "Club" :0.91846154 +} +mlflow.keras.save_model(model, "fifa_overall", signature=signature, input_example = input_example) \ No newline at end of file