Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escaping: Escape characters +-&|!(){}[]^"~*?:\ with \, e.g. \+
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Hi! I Was Taking A Look At The

Hi! I was taking a look at the https://pytorch-lightning.readthedocs.io/en/latest/common/lightning_cli.html and wanted to know if anyone has used clearml with it, will it work out of the box? Just call the task before? Thanks!

The LightningCLI uses jsonargparse which didn’t capture the configurations if I did something like:
task = Task.init(...) cli = LightningCLI(MyLightningModule, MyLightningDataModule)I did something like this, not sure if its the best way:
` class MyLightningCLI(LightningCLI):
def add_arguments_to_parser(self, parser):
parser.add_argument("--project-name", default="My Project")

def before_fit(self):
    project_name, task_name = self.config["project_name"], self.config["task_name"]
    task = Task.init(project_name=project_name, task_name=task_name)
    task.connect_configuration(self.config) `Would this allow me to change the configuration from the UI?
Posted 2 years ago
Votes Newest

Answers 5

Hi GrievingTurkey78
I think the main issue is the lack of support for jsonargparse , is that correct ?
(vanilla pytorch lightning is using argpraser, which seems to work out of the box)

Posted 2 years ago

Thanks GrievingTurkey78 , this is exactly what I was looking for!
Any chance you can open a GitHub issue ( jsonargparse + lighting support) ?
I really want to make sure this issue is addressed 🙂
BTW: this is only if jsonargparse is installed:

Posted 2 years ago

Yes AgitatedDove14 , I am not sure what they use by default. Here is a simple working example:
` from typing import Optional

import torch
from clearml import Task
from pytorch_lightning import LightningDataModule, LightningModule
from pytorch_lightning.utilities.cli import LightningCLI
from torch.utils.data import DataLoader, Dataset, Subset

class RandomDataset(Dataset):
def init(self, size, length):
self.len = length
self.data = torch.randn(length, size)

def __getitem__(self, index):
    return self.data[index]

def __len__(self):
    return self.len

class BoringModel(LightningModule):
def init(self):
Testing PL Module

    Use as follows:
    - subclass
    - modify the behavior for what you want

    class TestModel(BaseTestModel):
        def training_step(...):
            # do your own thing


    model = BaseTestModel()
    model.training_epoch_end = None

    self.layer = torch.nn.Linear(32, 2)

def forward(self, x):
    return self.layer(x)

def loss(self, batch, prediction):
    # An arbitrary loss to have a loss that updates the model weights during `Trainer.fit` calls
    return torch.nn.functional.mse_loss(prediction, torch.ones_like(prediction))

def step(self, x):
    x = self(x)
    out = torch.nn.functional.mse_loss(x, torch.ones_like(x))
    return out

def training_step(self, batch, batch_idx):
    output = self(batch)
    loss = self.loss(batch, output)
    return {"loss": loss}

def training_step_end(self, training_step_outputs):
    return training_step_outputs

def training_epoch_end(self, outputs) -> None:
    torch.stack([x["loss"] for x in outputs]).mean()

def validation_step(self, batch, batch_idx):
    output = self(batch)
    loss = self.loss(batch, output)
    return {"x": loss}

def validation_epoch_end(self, outputs) -> None:
    torch.stack([x["x"] for x in outputs]).mean()

def test_step(self, batch, batch_idx):
    output = self(batch)
    loss = self.loss(batch, output)
    return {"y": loss}

def test_epoch_end(self, outputs) -> None:
    torch.stack([x["y"] for x in outputs]).mean()

def configure_optimizers(self):
    optimizer = torch.optim.SGD(self.layer.parameters(), lr=0.1)
    lr_scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=1)
    return [optimizer], [lr_scheduler]

def train_dataloader(self):
    return DataLoader(RandomDataset(32, 64))

def val_dataloader(self):
    return DataLoader(RandomDataset(32, 64))

def test_dataloader(self):
    return DataLoader(RandomDataset(32, 64))

def predict_dataloader(self):
    return DataLoader(RandomDataset(32, 64))

class BoringDataModule(LightningDataModule):
def init(self, data_dir: str = "./"):
self.data_dir = data_dir
self.non_picklable = None
self.checkpoint_state: Optional[str] = None

def prepare_data(self):
    self.random_full = RandomDataset(32, 64 * 4)

def setup(self, stage: Optional[str] = None):
    if stage == "fit" or stage is None:
        self.random_train = Subset(self.random_full, indices=range(64))
        self.dims = self.random_train[0].shape

    if stage in ("fit", "validate") or stage is None:
        self.random_val = Subset(self.random_full, indices=range(64, 64 * 2))

    if stage == "test" or stage is None:
        self.random_test = Subset(self.random_full, indices=range(64 * 2, 64 * 3))
        self.dims = getattr(self, "dims", self.random_test[0].shape)

    if stage == "predict" or stage is None:
        self.random_predict = Subset(
            self.random_full, indices=range(64 * 3, 64 * 4)
        self.dims = getattr(self, "dims", self.random_predict[0].shape)

def train_dataloader(self):
    return DataLoader(self.random_train)

def val_dataloader(self):
    return DataLoader(self.random_val)

def test_dataloader(self):
    return DataLoader(self.random_test)

def predict_dataloader(self):
    return DataLoader(self.random_predict)

if name == "main":
task = Task.init(project_name="examples")
cli = LightningCLI(BoringModel, BoringDataModule) The expected behavior would be to have both the LightningDataModule and LightningModule ` parameters on the configuration tab > args of the UI but they are not there.

Posted 2 years ago

Nice catch AgitatedDove14 ! Sure I’ll open the issue right now.

Posted 2 years ago
5 Answers
2 years ago
8 months ago