Skip to content

Commit

Permalink
Update for latest Comet SDK version
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothiraldan committed Jun 13, 2024
1 parent fb8bcab commit 0bcbe29
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 34 deletions.
6 changes: 3 additions & 3 deletions comet_for_mlflow/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ def main():
help="set the directory to store prepared runs; only relevant with --no-upload",
)
parser.add_argument(
"--force-reupload",
"--force-upload",
action="store_true",
default=False,
help="Force reupload of prepared experiments that were previously uploaded",
help="Force the upload of prepared experiments even if they were previously uploaded",
)
command_group = parser.add_mutually_exclusive_group()
command_group.add_argument(
Expand Down Expand Up @@ -98,7 +98,7 @@ def main():
args.upload,
args.api_key,
args.output_dir,
args.force_reupload,
args.force_upload,
args.mlflow_store_uri,
args.answer,
args.email,
Expand Down
6 changes: 3 additions & 3 deletions comet_for_mlflow/comet_for_mlflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(
upload_experiment,
api_key,
output_dir,
force_reupload,
force_upload,
mlflow_store_uri,
answer,
email,
Expand Down Expand Up @@ -146,7 +146,7 @@ def __init__(

self.upload_experiment = upload_experiment
self.output_dir = output_dir
self.force_reupload = force_reupload
self.force_upload = force_upload
self.mlflow_store_uri = mlflow_store_uri

def prepare(self):
Expand Down Expand Up @@ -486,7 +486,7 @@ def upload(self, prepared_data):
upload_single_offline_experiment(
archive_path,
self.api_key,
force_reupload=self.force_reupload,
force_upload=self.force_upload,
display_level="debug",
)

Expand Down
21 changes: 8 additions & 13 deletions examples/keras-example/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
"""Trains and evaluate a simple MLP
on the Reuters newswire topic classification task.
"""
from __future__ import print_function

import keras
import mlflow.keras
import mlflow
import numpy as np
from keras.datasets import reuters
from keras.layers import Activation, Dense, Dropout
from keras.models import Sequential
from keras.preprocessing.text import Tokenizer
from tensorflow import keras
from tensorflow.keras.datasets import reuters
from tensorflow.keras.layers import Activation, Dense, Dropout
from tensorflow.keras.models import Sequential
from tensorflow.keras.preprocessing.text import Tokenizer

mlflow.keras.autolog()
mlflow.tensorflow.autolog()

max_words = 1000
batch_size = 32
Expand All @@ -38,8 +36,7 @@
print("x_test shape:", x_test.shape)

print(
"Convert class vector to binary class matrix "
"(for use with categorical_crossentropy)"
"Convert class vector to binary class matrix (for use with categorical_crossentropy)"
)
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)
Expand Down Expand Up @@ -67,5 +64,3 @@
score = model.evaluate(x_test, y_test, batch_size=batch_size, verbose=1)
print("Test score:", score[0])
print("Test accuracy:", score[1])

mlflow.keras.log_model(model, "models")
23 changes: 9 additions & 14 deletions examples/model-registry-example/run.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""Trains and evaluate a simple MLP
on the Reuters newswire topic classification task.
"""
from __future__ import print_function

import keras
import mlflow.keras
import mlflow
import numpy as np
from keras.datasets import reuters
from keras.layers import Activation, Dense, Dropout
from keras.models import Sequential
from keras.preprocessing.text import Tokenizer
from tensorflow import keras
from tensorflow.keras.datasets import reuters
from tensorflow.keras.layers import Activation, Dense, Dropout
from tensorflow.keras.models import Sequential
from tensorflow.keras.preprocessing.text import Tokenizer

mlflow.set_tracking_uri("sqlite:///db.sqlite")


mlflow.keras.autolog()

mlflow.log_param("Test", "FOO")
mlflow.tensorflow.autolog()

max_words = 1000
batch_size = 32
Expand All @@ -43,8 +39,7 @@
print("x_test shape:", x_test.shape)

print(
"Convert class vector to binary class matrix "
"(for use with categorical_crossentropy)"
"Convert class vector to binary class matrix (for use with categorical_crossentropy)"
)
y_train = keras.utils.to_categorical(y_train, num_classes)
y_test = keras.utils.to_categorical(y_test, num_classes)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
with open("HISTORY.md") as history_file:
history = history_file.read()

requirements = ["mlflow", "comet_ml>=3.1.1", "tabulate", "tqdm", "typing"]
requirements = ["mlflow", "comet_ml>=3.39.0", "tabulate", "tqdm", "typing"]


setup(
Expand Down

0 comments on commit 0bcbe29

Please sign in to comment.