Skip to content

Commit

Permalink
Clean the last reference to comet_ml.init
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothiraldan committed Jul 9, 2024
1 parent dd0d430 commit 8e448a0
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 43 deletions.
38 changes: 22 additions & 16 deletions catalyst/comet_catalyst_example.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
import comet_ml
# coding: utf-8

import os

import comet_ml

from torch import nn, optim
from torch.utils.data import DataLoader

from catalyst import dl
from catalyst.contrib.datasets import MNIST
from catalyst.data import ToTensor
from catalyst.loggers.comet import CometLogger
from catalyst.contrib.datasets import MNIST

comet_ml.init()
comet_ml.login()
logger = CometLogger(logging_frequency=10)

model = nn.Sequential(nn.Flatten(), nn.Linear(28 * 28, 10))
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=0.02)



loaders = {
"train": DataLoader(
MNIST(os.getcwd(), train=True, download=True, transform=ToTensor()), batch_size=32
MNIST(os.getcwd(), train=True, download=True, transform=ToTensor()),
batch_size=32,
),
"valid": DataLoader(
MNIST(os.getcwd(), train=False, download=True, transform=ToTensor()), batch_size=32
MNIST(os.getcwd(), train=False, download=True, transform=ToTensor()),
batch_size=32,
),
}

Expand All @@ -37,14 +43,16 @@
loaders=loaders,
num_epochs=1,
hparams={
'lr': 0.02,
'betas': (0.9, 0.999),
'eps': 1e-08,
'weight_decay': 0,
'amsgrad': False
"lr": 0.02,
"betas": (0.9, 0.999),
"eps": 1e-08,
"weight_decay": 0,
"amsgrad": False,
},
callbacks=[
dl.AccuracyCallback(input_key="logits", target_key="targets", topk_args=(1, 3, 5)),
dl.AccuracyCallback(
input_key="logits", target_key="targets", topk_args=(1, 3, 5)
),
dl.PrecisionRecallF1SupportCallback(
input_key="logits", target_key="targets", num_classes=10
),
Expand All @@ -55,7 +63,5 @@
minimize_valid_metric=True,
verbose=True,
load_best_on_end=True,
loggers={
"comet": logger
}
)
loggers={"comet": logger},
)
6 changes: 3 additions & 3 deletions guides/tracking-ml-training/Comet_in_Notebooks.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"id": "jS7jwZNSVH9_"
},
"source": [
"# Configuration through `comet.init()`"
"# Login to Comet"
]
},
{
Expand All @@ -40,7 +40,7 @@
"source": [
"import comet_ml\n",
"\n",
"comet_ml.login(project_name=\"comet-in-notebooks\")"
"comet_ml.login()"
]
},
{
Expand All @@ -60,7 +60,7 @@
},
"outputs": [],
"source": [
"experiment = comet_ml.Experiment()\n",
"experiment = comet_ml.Experiment(project_name=\"comet-in-notebooks\")\n",
"\n",
"for idx, value in enumerate(range(0, 100, 10)):\n",
" experiment.log_metric(\"accuracy\", value / 100, step=idx)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"outputs": [],
"source": [
"#### Import Comet ####\n",
"from comet_ml import Experiment, init\n",
"from comet_ml import Experiment, login\n",
"\n",
"#### Import Dependencies ####\n",
"import xgboost as xgb\n",
Expand All @@ -68,7 +68,7 @@
"metadata": {},
"outputs": [],
"source": [
"init()\n",
"login()\n",
"\n",
"experiment = Experiment(project_name=\"comet-example-xgboost-seldon\")"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from comet_ml import Experiment, init
from comet_ml import Experiment, login

import matplotlib
import numpy as np
Expand All @@ -13,9 +13,9 @@
matplotlib.use("agg")

# Login to Comet if needed
init(project_name="comet-example-shap-hello-world")
login()

experiment = Experiment()
experiment = Experiment(project_name="comet-example-shap-hello-world")

# Model / data parameters
num_classes = 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# coding: utf-8
from comet_ml import Experiment, init
from comet_ml import Experiment, login

import optuna

# Login to Comet if needed
init()
login()


def objective(trial):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"source": [
"Assuming you have already imported Comet at the beginning of your script, all you have to do now is set the `comet_config` argument when initializing TensorboardX's SummaryWriter. \n",
"\n",
"`comet_config` is just a dictionary that allows you to set your workspace, project name and API key if you haven't already done so through `comet.init()`. \n",
"`comet_config` is just a dictionary that allows you to set your workspace, project name and API key if you haven't already done so through `comet.login()`. \n",
"\n",
"The dictionary has the following fields\n",
"```\n",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding: utf-8
from comet_ml import Experiment, init
from comet_ml import Experiment, login
from comet_ml.integration.pytorch import log_model, watch

import torch
Expand All @@ -21,7 +21,7 @@


# Login to Comet if needed
init()
login()

experiment = Experiment(project_name="comet-example-pytorch-mnist")
experiment.log_parameters(hyper_params)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding: utf-8
import random

from comet_ml import ConfusionMatrix, Experiment, init
from comet_ml import ConfusionMatrix, Experiment, login
from comet_ml.integration.pytorch import log_model

import numpy as np
Expand All @@ -23,7 +23,7 @@
}

# Login to Comet if needed
init()
login()


experiment = Experiment(project_name="comet-example-pytorch-rich-logging")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# coding: utf-8

# Import Comet
from comet_ml import Experiment, init
from comet_ml import Experiment, login

import pandas as pd
from sklearn.datasets import fetch_california_housing
Expand All @@ -11,7 +11,7 @@
import xgboost as xgb

# Login to Comet if needed
init()
login()

experiment = Experiment(project_name="comet-example-xgboost-california")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

import os

from comet_ml import init
from comet_ml import login

import kfp
import kfp.dsl as dsl
from kubernetes.client.models import V1EnvVar

# Login to Comet if needed
init()
login()


COMET_PROJECT_NAME = "comet-example-kubeflow-hello-world"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: utf-8

from comet_ml import init
from comet_ml import login
from comet_ml.integration.metaflow import comet_flow

from metaflow import FlowSpec, step
Expand Down Expand Up @@ -46,6 +46,6 @@ def end(self):

if __name__ == "__main__":
# Login to Comet if needed
init()
login()

HelloFlow()
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding: utf-8

from comet_ml import init
from comet_ml import login
from comet_ml.integration.metaflow import comet_flow

from metaflow import FlowSpec, JSONType, Parameter, card, step
Expand Down Expand Up @@ -122,6 +122,6 @@ def end(self):

if __name__ == "__main__":
# Login to Comet if needed
init()
login()

RegressionFlow()
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# coding: utf-8
import os

from comet_ml import init
from comet_ml import login

import google.cloud.aiplatform as aip
import kfp
import kfp.v2.dsl as dsl

# Login to Comet if needed
init()
login()


COMET_PROJECT_NAME = "comet-example-vertex-hello-world"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# coding: utf-8
import os

from comet_ml import init
from comet_ml import login

import google.cloud.aiplatform as aip
from kfp import compiler, dsl

# Login to Comet if needed
init()
login()


COMET_PROJECT_NAME = "comet-example-vertex-v2-hello-world"
Expand Down

0 comments on commit 8e448a0

Please sign in to comment.