repo stringclasses 454
values | file_path stringlengths 5 201 | extension stringclasses 1
value | content stringlengths 8 509k | num_lines int64 3 16.9k | size_bytes int64 8 511k |
|---|---|---|---|---|---|
wandb | tests/system_tests/test_core/test_wandb_init_reinit.py | .py | """Tests for the `reinit` setting."""
import pytest
import wandb
def test_reinit_create_new__does_not_modify_wandb_run():
with wandb.init(mode="offline", reinit="create_new"):
assert wandb.run is None
def test_reinit_create_new__fails_on_id_conflict():
with wandb.init(mode="offline") as run1:
... | 57 | 1,699 |
wandb | tests/system_tests/test_core/test_metric_full.py | .py | import math
import pytest
import wandb
@pytest.mark.parametrize("summary_type", [None, "copy"])
def test_default_summary_type_is_last(wandb_backend_spy, summary_type):
with wandb.init() as run:
run.define_metric("*", summary=summary_type)
run.log(dict(mystep=1, val=2))
run.log(dict(mystep... | 436 | 13,666 |
wandb | tests/system_tests/test_core/test_footer.py | .py | from __future__ import annotations
import re
import wandb
def _run_history_lines(lines: list[str]) -> list[str]:
"""Returns the lines corresponding to the run history footer."""
try:
header_idx = lines.index("wandb: Run history:")
end_idx = lines.index("wandb:", header_idx)
except ValueE... | 142 | 3,991 |
wandb | tests/system_tests/test_core/scripts/unix_socket_cleanup_child.py | .py | """Child process for Unix socket temp-dir cleanup system tests."""
from __future__ import annotations
import signal
import sys
import wandb
from wandb.sdk import wandb_setup
def main() -> int:
run = wandb.init(
id="unix-socket-cleanup-child",
mode="offline",
tags=["unix-socket-cleanup"]... | 34 | 713 |
wandb | tests/system_tests/test_automations/test_automations_api.py | .py | from __future__ import annotations
import math
from collections import deque
from collections.abc import Callable, Generator
from itertools import islice
from typing import TYPE_CHECKING, Any
import wandb
from pytest import FixtureRequest, fixture, mark, raises, skip
from wandb.apis.public import ArtifactCollection, ... | 1,017 | 34,838 |
wandb | tests/system_tests/test_automations/conftest.py | .py | from __future__ import annotations
import secrets
from collections.abc import Callable, Generator
from functools import lru_cache
from string import ascii_lowercase, digits
from typing import TYPE_CHECKING, TypeAlias
import wandb
from pytest import FixtureRequest, fixture, skip
from wandb import Artifact
from wandb._... | 482 | 16,059 |
wandb | tests/system_tests/test_sweep/train_with_import_readline.py | .py | import wandb
# For use with test_wandb_agent_full.py::test_agent_subprocess_with_import_readline
def main() -> None:
with wandb.init() as run:
print("Importing readline...")
# `import readline` causes deadlock if parent launches subprocess using progress_group=0
# without a pty
im... | 35 | 932 |
wandb | tests/system_tests/test_sweep/test_wandb_sweep.py | .py | """Sweep tests."""
import json
import sys
from typing import Any
import pytest
import wandb
import wandb.apis
from wandb.cli import cli
# Sweep configs used for testing
SWEEP_CONFIG_GRID: dict[str, Any] = {
"name": "mock-sweep-grid",
"method": "grid",
"parameters": {"param1": {"values": [1, 2, 3]}},
}
SW... | 302 | 9,491 |
wandb | tests/system_tests/test_sweep/test_sweep_public_api.py | .py | import json
import pytest
import wandb
from wandb import Api
from wandb.apis.public.sweeps import Sweep
from wandb.errors import UnsupportedError
from wandb.proto import wandb_internal_pb2 as pb
from wandb.sdk.internal.internal_api import Api as InternalApi
from tests.fixtures.wandb_backend_spy import WandbBackendSpy... | 262 | 8,154 |
wandb | tests/system_tests/test_sweep/test_launch_scheduler.py | .py | """Sweep tests."""
import asyncio
from unittest.mock import Mock, patch
import pytest
import wandb
from wandb.apis import internal, public
from wandb.errors import CommError
from wandb.sdk.launch.sweeps import SchedulerError, SweepNotFoundError, load_scheduler
from wandb.sdk.launch.sweeps.scheduler import (
RunSt... | 817 | 25,184 |
wandb | tests/system_tests/test_sweep/test_wandb_agent.py | .py | """Agent tests."""
import os
import platform
import signal
import subprocess
import sys
import textwrap
from pathlib import Path
from unittest import mock
import pytest
from wandb.apis.public.sweeps import Agent as PublicAgent
from wandb.sdk.launch.sweeps.utils import (
create_sweep_command,
create_sweep_comm... | 281 | 8,026 |
wandb | tests/system_tests/test_sweep/test_wandb_agent_full.py | .py | """Agent tests."""
import queue
import threading
import time
from concurrent.futures import ThreadPoolExecutor
import wandb
import wandb.agents.pyagent as pyagent
from wandb.apis.public import Api
from .test_wandb_sweep import SWEEP_CONFIG_GRID
def test_public_api_sweep_agent_retrieves_running_agent(user):
"""... | 142 | 4,899 |
wandb | tests/system_tests/test_sweep/test_sweep_utils.py | .py | import json
import pytest
import yaml
from wandb.sdk.launch.sweeps import utils
def test_parse_sweep_id():
parts = {"name": "test/test/test"}
utils.parse_sweep_id(parts)
assert parts == {"name": "test", "entity": "test", "project": "test"}
parts = {"name": 1}
assert utils.parse_sweep_id(parts) =... | 128 | 3,120 |
wandb | tests/system_tests/test_sweep/conftest.py | .py | import pytest
from wandb.cli import cli
@pytest.fixture(autouse=True)
def _clear_cli_api(monkeypatch: pytest.MonkeyPatch) -> None:
"""Reset cli._api before each test.
CliRunner invokes CLI commands in-process, so the module-level cache at
cli._api survives across tests. A real CLI invocation gets a fresh... | 16 | 564 |
wandb | tests/system_tests/test_sweep/mock_scripts/parent_script_with_term_timeout.py | .py | import os
import queue
import signal
import sys
import threading
import time
from wandb.wandb_agent import Agent
child_script = sys.argv[1]
term_timeout = int(sys.argv[2])
class _StubApi:
def sweep(self, sweep_id, spec):
return None
def register_agent(self, host, sweep_id=None):
return {"id... | 65 | 1,390 |
wandb | tests/system_tests/test_experimental/test_client_csharp.py | .py | import os
import pathlib
import subprocess
import pytest
@pytest.mark.timeout(300)
def test_client_sharp(wandb_backend_spy):
script_path = (
pathlib.Path(__file__).parent.parent.parent.parent
/ "experimental"
/ "client-csharp"
/ "examples"
/ "Basic"
/ "build_and_ru... | 36 | 885 |
wandb | tests/system_tests/test_registries/test_link_registry.py | .py | from __future__ import annotations
from typing import Literal
import wandb
from pytest import FixtureRequest, MonkeyPatch, fixture, mark, param, skip
from typing_extensions import assert_never
from wandb import Api, Artifact
from wandb.apis.public.registries.registry import Registry
@fixture(
params=[
[... | 170 | 5,025 |
wandb | tests/system_tests/test_registries/test_registry_members.py | .py | from __future__ import annotations
import os
from collections.abc import Callable, Generator
from typing import TYPE_CHECKING
from pytest import fixture, mark, skip
from wandb import Api
from wandb.apis.public import Registry, Team, User
from wandb.apis.public.registries._members import MemberKind
if TYPE_CHECKING:
... | 288 | 11,283 |
wandb | tests/system_tests/test_registries/test_registry.py | .py | from __future__ import annotations
from collections.abc import Callable, Generator
from itertools import islice, product
from unittest.mock import patch
import wandb
from pytest import fixture, mark, param, raises
from wandb import Api, Artifact
from wandb._strutils import b64decode_ascii
from wandb.apis.public.regis... | 801 | 28,584 |
wandb | tests/system_tests/test_registries/test_registry_artifacts_public_api.py | .py | from __future__ import annotations
from typing import Any
from urllib.parse import quote
import wandb
from pytest import fixture
from wandb import Api, Artifact
from wandb._strutils import b64encode_ascii, nameof
from wandb.apis.public.registries.registry import Registry
from wandb.sdk.artifacts._generated import (
... | 159 | 4,473 |
wandb | tests/system_tests/test_registries/conftest.py | .py | from __future__ import annotations
import os
from collections.abc import Callable
from typing import TYPE_CHECKING, Literal
import wandb
from pytest import FixtureRequest, fixture, skip
from pytest_mock import MockerFixture
from wandb import Api, Artifact
from wandb.apis.public.registries._utils import fetch_org_enti... | 236 | 8,167 |
wandb | tests/system_tests/test_system_metrics/test_system_monitor.py | .py | import time
import wandb
def test_run_system_metrics(wandb_backend_spy):
with wandb.init(
settings=wandb.Settings(
x_file_stream_transmit_interval=1,
x_stats_sampling_interval=0.1,
x_stats_buffer_size=100,
)
) as run:
# Wait for the first metrics to... | 50 | 1,750 |
wandb | tests/system_tests/test_api/test_public_api_history.py | .py | from __future__ import annotations
import pathlib
import tempfile
from typing import Any
import pytest
import wandb
from wandb.apis.public import DownloadHistoryResult, IncompleteRunHistoryError, Run
from wandb.errors import CommError
def stub_run_parquet_history(
wandb_backend_spy,
parquet_file_server,
... | 440 | 12,306 |
wandb | tests/system_tests/test_api/test_service_api.py | .py | from types import SimpleNamespace
from wandb.apis.public.service_api import ServiceApi
from wandb.proto import wandb_internal_pb2 as pb
from wandb.sdk import wandb_setup
from wandb.sdk.lib.service.service_connection import WandbApiFailedError
from tests.fixtures.wandb_backend_spy import WandbBackendSpy
def stub_ser... | 146 | 4,187 |
wandb | tests/system_tests/test_api/test_public_api_organizations.py | .py | """System tests for `Api.organization()` and the public `Organization` model."""
from __future__ import annotations
from collections.abc import Callable
from typing import TYPE_CHECKING
from pytest import fixture, raises
from wandb import CommError
if TYPE_CHECKING:
from wandb import Api
@fixture
def org_name... | 45 | 1,382 |
wandb | tests/system_tests/test_api/test_public_api_run_summary.py | .py | import pytest
import wandb
def test_delete_summary_metric_w_no_lazyload(user):
with wandb.init(project="test") as run:
run_id = run.id
metric = "test_val"
for i in range(10):
run.log({metric: i})
run = wandb.Api().run(f"test/{run_id}")
del run.summary[metric]
run.... | 20 | 471 |
wandb | tests/system_tests/test_api/conftest.py | .py | """Fixtures for API tests."""
from __future__ import annotations
import http.server
import io
import socket
import socketserver
import threading
from collections.abc import Generator
import pyarrow as pa
import pyarrow.parquet as pq
import pytest
class ParquetFileHandler(http.server.SimpleHTTPRequestHandler):
... | 156 | 4,498 |
wandb | tests/system_tests/test_notebooks/test_notebooks.py | .py | import io
import json
import os
import pathlib
import re
import subprocess
import sys
from unittest import mock
import nbformat
import pytest
import wandb
import wandb.sdk.lib.ipython as wb_ipython
import wandb.util
def test_login_timeout(notebook):
with notebook("login_timeout.ipynb", skip_api_key_env=True) as ... | 287 | 9,624 |
wandb | tests/system_tests/test_notebooks/conftest.py | .py | import io
import os
import pathlib
import re
import shutil
import sys
from contextlib import contextmanager
from unittest.mock import MagicMock
import filelock
import IPython
import IPython.display
import nbformat
import pytest
import wandb
import wandb.util
from nbclient import NotebookClient
from nbclient.client imp... | 231 | 7,364 |
wandb | tests/system_tests/test_notebooks/test_jupyter_server/test_jupyter_server_notebooks.py | .py | """Test executing notebooks against running Jupyter servers."""
import nbformat
def test_jupyter_server_code_saving(wandb_backend_spy, jupyter_server, notebook_client):
notebook_name = "test_metadata.ipynb"
nb = nbformat.v4.new_notebook()
nb.cells = [
nbformat.v4.new_code_cell(
"""
... | 69 | 2,330 |
wandb | tests/system_tests/test_notebooks/test_jupyter_server/conftest.py | .py | import json
import socket
import tempfile
import threading
import time
from collections.abc import Callable, Generator
from pathlib import Path
import jupyter_core
import nbformat
import nest_asyncio2
import pytest
import requests
from jupyter_client.blocking.client import BlockingKernelClient
from jupyter_server.serv... | 269 | 9,078 |
wandb | tests/assets/test_mod.py | .py | import multiprocessing
import wandb
def mp_func():
"""Define at the module level to be pickle and send to the spawned process.
Required for multiprocessing.
"""
print("hello from the other side")
def main():
wandb.init()
context = multiprocessing.get_context("spawn")
p = context.Proces... | 21 | 384 |
wandb | tests/assets/notebooks/ipython_exit.py | .py | import wandb
wandb.init()
| 4 | 27 |
wandb | tests/assets/wandb/offline-run-20210216_154407-g9dvvkua/files/code/standalone_tests/code-toad.py | .py | import os
import wandb
os.environ["WANDB_CODE_DIR"] = "."
wandb.init(project="code-toad")
# wandb.run.log_code()
| 10 | 117 |
wandb | tests/assets/scripts/train.py | .py | import argparse
import math
import os
import pathlib
import random
import subprocess
import time
import tqdm
import wandb
def main(
project: str = "igena",
sleep: int = 1,
num_steps: int = 10,
eval_rate: int = 4,
):
run = wandb.init(
project=project,
settings=wandb.Settings(
... | 84 | 2,127 |
wandb | tests/assets/scripts/eval.py | .py | import argparse
import math
import random
import wandb
def main(attach_id: str, eval_step: int, project: str):
run = wandb.init(
id=attach_id,
project=project,
settings=wandb.Settings(
mode="shared",
console="off",
_disable_machine_info=True,
... | 43 | 949 |
wandb | parquet-rust-wrapper/hatch.py | .py | """Build script for arrow-rs-wrapper."""
from __future__ import annotations
import glob
import json
import os
import pathlib
import platform
import subprocess
class ArrowRsWrapperBuildError(Exception):
"""Raised when building arrow-rs-wrapper fails."""
def build_arrow_rs_wrapper(
cargo_binary: pathlib.Pat... | 121 | 4,071 |
clearml | setup.py | .py | """
ClearML Inc
https://github.com/clearml/clearml
"""
import os.path
# Always prefer setuptools over distutils
from setuptools import setup, find_packages
import codecs
def read_text(filepath):
with codecs.open(filepath, "r", encoding="utf-8") as f:
return f.read()
here = os.path.dirname(__file__)
# G... | 116 | 4,238 |
clearml | examples/advanced/multiple_tasks_single_process.py | .py | from clearml import Task
for i in range(3):
task = Task.init(
project_name="examples",
task_name=f"Same process, Multiple tasks, Task #{i}",
)
print(f"Task #{i} running")
print(f"Task #{i} done :) ")
task.close()
| 12 | 251 |
clearml | examples/advanced/model_embedding.py | .py | import os
import sys
import argparse
import json
import requests
import numpy as np
from typing import List, Dict, Any
try:
from PyPDF2 import PdfReader
except ImportError:
raise ImportError(
"PyPDF2 is required to extract text from PDF files. Install via `pip install PyPDF2`."
)
def chunk_text(t... | 228 | 7,269 |
clearml | examples/advanced/execute_remotely_example.py | .py | """
ClearML - Example of remote_execution with Pytorch mnist training
The task.remote_execution option is used when it's needed to run part of the code locally and then move it for
full execution remotely. When running locally, the task.remote_execution() will complete the currently running task and
enqueue it to a ch... | 247 | 7,283 |
clearml | examples/advanced/model_finetuning/finetune.py | .py | import argparse
import logging
from transformers import AutoConfig
from clearml import Task, Dataset, InputModel, OutputModel
from pathlib import Path
from datasets import load_dataset
from transformers import (
AutoTokenizer,
AutoModelForCausalLM,
Trainer,
TrainingArguments,
default_data_collator,... | 175 | 5,463 |
clearml | examples/advanced/model_finetuning/extract.py | .py | import subprocess
import argparse
import json
import ast
from pathlib import Path
from clearml import Dataset
import libcst as cst
def clone_repo(repo_url: str, output_dir: Path) -> Path:
"""
Clone the given git repository into output_dir. Returns the path to the cloned repo.
If the destination exists, s... | 146 | 4,760 |
clearml | examples/advanced/model_finetuning/upload_local_model.py | .py | import argparse
from clearml import OutputModel, Task
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model-path", type=str, help="Path to the model to be uploaded to ClearML"
)
parser.add_argument(
"--model-name", type=str, help="Model name - to be display... | 25 | 701 |
clearml | examples/reporting/using_artifacts_example.py | .py | # Using artifacts example
"""
Upload artifacts from a Task, and then a different Task can access and utilize the data from that artifact.
"""
from clearml import Task
from time import sleep
task1 = Task.init(project_name='examples', task_name='Create artifact')
# upload data file to the initialized task, inputting a n... | 31 | 1,368 |
clearml | examples/reporting/config_files.py | .py | # ClearML - example code for logging configuration files to Task":
#
import json
from pathlib import Path
import yaml
from clearml import Task
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init(project_name='FirstTrial', task_name='config_files_example')... | 37 | 1,084 |
clearml | examples/reporting/model_reporting_plots.py | .py | # ClearML - Example of manual model reporting
from clearml import Task, OutputModel
from clearml.utilities.plotly_reporter import SeriesInfo
import pandas as pd
import numpy as np
# Connecting ClearML with the current process,
task = Task.init(project_name="examples", task_name="Model reporting plots example")
# Crea... | 63 | 1,889 |
clearml | examples/reporting/plotly_reporting.py | .py | # ClearML - Example of Plotly integration and reporting
#
from clearml import Task
import plotly.express as px
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init('examples', 'plotly reporting')
print('reporting plotly figures')
# Iris dataset
df = px.da... | 23 | 607 |
clearml | examples/reporting/text_reporting.py | .py | # ClearML - Example of manual graphs and statistics reporting
#
from __future__ import print_function
import logging
import sys
import six
from clearml import Logger, Task
def report_logs(logger):
# type: (Logger) -> None
"""
reporting text to logs section
:param logger: The task.logger to use for... | 93 | 2,832 |
clearml | examples/reporting/hyper_parameters.py | .py | # ClearML - example code for logging into "CONFIGURATION":
# - ArgumentParser parameter logging
# - user properties logging
# - logging of hyperparameters via dictionary
# - logging of hyperparameters via TaskParameters
# - logging of configuration objects via TaskParameters
#
from __future__ import absolute_import
fro... | 122 | 3,878 |
clearml | examples/reporting/pandas_reporting.py | .py | # ClearML - Example of manual graphs and statistics reporting
#
import pandas as pd
from clearml import Task, Logger
def report_table(logger, iteration=0):
# type: (Logger, int) -> ()
"""
reporting tables to the plots section
:param logger: The task.logger to use for sending the plots
:param it... | 69 | 2,170 |
clearml | examples/reporting/scatter_hist_confusion_mat_reporting.py | .py | # ClearML - Example of manual graphs and statistics reporting
#
import numpy as np
from clearml import Task, Logger
def report_plots(logger, iteration=0):
# type: (Logger, int) -> ()
"""
reporting plots to plots section
:param logger: The task.logger to use for sending the plots
:param iteration... | 135 | 3,542 |
clearml | examples/reporting/matplotlib_manual_reporting.py | .py | # ClearML - Example of Matplotlib and Seaborn integration and reporting
#
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from clearml import Task
# Connecting ClearML with the current process,
# from here on everything is logged automatically
# Create a new task, disable automatic matplotlib ... | 75 | 1,903 |
clearml | examples/reporting/scalar_reporting.py | .py | # ClearML - Example of manual graphs and statistics reporting
#
from clearml import Task, Logger
def report_scalars(logger):
# type: (Logger) -> ()
"""
reporting scalars to scalars section
:param logger: The task.logger to use for sending the scalars
"""
# report two scalar series on the same ... | 51 | 1,696 |
clearml | examples/reporting/matplotlib_automatic_reporting.py | .py | # ClearML - Example of Matplotlib and Seaborn integration and reporting
#
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from clearml import Task
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init(project_name='examples', task_nam... | 59 | 1,705 |
clearml | examples/reporting/image_reporting.py | .py | # ClearML - Example of manual graphs and statistics reporting
#
import os
import numpy as np
from PIL import Image
from clearml import Task, Logger
def report_debug_images(logger, iteration=0):
# type: (Logger, int) -> ()
"""
reporting images to debug samples section
:param logger: The task.logger ... | 69 | 2,193 |
clearml | examples/reporting/html_reporting.py | .py | # ClearML - Example of manual graphs and statistics reporting
#
import math
import numpy as np
from bokeh.models import ColumnDataSource, GraphRenderer, Ellipse, StaticLayoutProvider
from bokeh.palettes import Spectral5, Spectral8
from bokeh.plotting import figure, output_file, save
from bokeh.sampledata.autompg impo... | 247 | 8,569 |
clearml | examples/reporting/artifacts.py | .py | import os
from time import sleep
import pandas as pd
import numpy as np
from PIL import Image
from clearml import Task
def main():
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init(project_name='examples', task_name='Artifacts example')
... | 57 | 2,094 |
clearml | examples/reporting/3d_plots_reporting.py | .py | # ClearML - Example of manual graphs and statistics reporting
#
import numpy as np
from clearml import Task, Logger
def report_plots(logger, iteration=0):
# type: (Logger, int) -> None
"""
reporting plots to plots section
:param logger: The task.logger to use for sending the plots
:param iteratio... | 65 | 1,665 |
clearml | examples/reporting/model_reporting.py | .py | # ClearML - Example of manual model reporting
from clearml import Task, OutputModel
# Connecting ClearML with the current process,
task = Task.init(project_name="examples", task_name="Model reporting example")
# Create output model and connect it to the task
output_model = OutputModel(task=task)
# Optional: add labe... | 22 | 788 |
clearml | examples/reporting/artifacts_retrieval.py | .py | # ClearML - example code, retrieve other task artifacts and print the artifacts
# Please run examples/reporting/artifacts.py example before running this example
#
from pprint import pprint
from clearml import Task
def main():
# Getting the task we want to get the artifacts from
artifacts_task = Task.get_task... | 69 | 3,020 |
clearml | examples/reporting/media_reporting.py | .py | # ClearML - Example reporting video or audio links/file
#
import os
from clearml import Task, Logger
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init(project_name="examples", task_name="Audio and video reporting")
print('reporting audio and video sampl... | 27 | 977 |
clearml | examples/distributed/subprocess_example.py | .py | # ClearML - example of multiple sub-processes interacting and reporting to a single master experiment
import multiprocessing
import os
import subprocess
import sys
import time
from argparse import ArgumentParser
from random import randint
from clearml import Task
def mp_worker(arguments):
print("sub process", o... | 146 | 4,270 |
clearml | examples/distributed/pytorch_distributed_example.py | .py | # ClearML - example of ClearML torch distributed support
# notice all nodes will be reporting to the master Task (experiment)
import os
import subprocess
import sys
from argparse import ArgumentParser
from datetime import timedelta
from math import ceil
from random import Random
import torch as th
import torch.distrib... | 189 | 6,639 |
clearml | examples/hyperdatasets/dataview.py | .py | import argparse
from clearml import Task
from tqdm import tqdm
# ClearML HyperDataset helpers for dataset resolution and dataview streaming
from clearml.hyperdatasets import (
HyperDatasetManagement,
DataView,
)
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--dataset", required=True, he... | 56 | 1,997 |
clearml | examples/hyperdatasets/create_qa_entries.py | .py | """
Create a HyperDataset populated with raw Q&A pairs.
The script demonstrates how to build Q&A entries, optionally enrich them with
vector embeddings generated by a small local model, and upload them to a
HyperDataset version.
Example usage:
python examples/hyperdatasets/create_qa_entries.py \
--projec... | 348 | 11,979 |
clearml | examples/hyperdatasets/finetune_qa_lora.py | .py | """
Fine-tune a base LLM with LoRA adapters on HyperDataset Q&A entries using Hugging Face's Trainer.
This variant keeps the ClearML multi-node bootstrap from the original script but delegates the
training loop to `transformers.Trainer` for a more compact implementation.
Example local run (single node, all GPUs):
... | 500 | 19,469 |
clearml | examples/hyperdatasets/create_image_entries.py | .py | """Create a HyperDataset populated with local image files.
The script demonstrates how to use `DataEntryImage` along with
optional vector embeddings computed from each image. Ten sample images are
shipped under `examples/hyperdatasets/sample_images`, but you can point the
script at any directory of JPEG/PNG assets.
E... | 208 | 7,426 |
clearml | examples/hyperdatasets/create_doc_entries.py | .py | """Create a HyperDataset populated with Markdown documentation links.
The script downloads a predefined (or user-supplied) list of Markdown files,
captures their content and metadata inside HyperDataset entries, and
optionally generates vector embeddings for semantic search.
Example usage::
python examples/hyper... | 236 | 8,272 |
clearml | examples/hyperdatasets/vector_search.py | .py | """
Search HyperDataset entries using vector similarity.
The script embeds either free-form text or an input file (typically an image)
and executes a vector search against a HyperDataset version that already stores
embeddings under the specified metadata field.
Examples::
# Text query (matching qa_entries_create... | 268 | 8,968 |
clearml | examples/hyperdatasets/dataview_pytorch_dataloader.py | .py | import argparse
import os
from typing import Dict, Any, Iterable
import torch
# ClearML utilities for resolving datasets and creating dataview iterators
from clearml.hyperdatasets import (
HyperDatasetManagement,
DataView,
)
class HyperDatasetIterable(torch.utils.data.IterableDataset):
"""PyTorch Iterab... | 111 | 4,386 |
clearml | examples/hyperdatasets/create_coco_hyperdataset.py | .py | """
Download a subset of COCO and convert it into a ClearML HyperDataset.
The script fetches the COCO 2017 annotations JSON and downloads image files on
an as-needed basis (defaulting to the validation split). Each COCO record is
converted into a `DataEntryImage` with per-object bounding boxes, polygon
segmentations, ... | 376 | 13,196 |
clearml | examples/hyperdatasets/legacy/data-registration/register_dataset_with_roi.py | .py | """
How to register data with ROIs and metadata from a json file.
Create a list of ROI's for each image in the metadata format required by a frame.
Notice: This is a custom parser for a specific dataset. Each dataset requires a different parser.
You can run this example from this dir with:
python register_dataset_wi... | 149 | 5,453 |
clearml | examples/hyperdatasets/legacy/data-registration/register_dataset_masks.py | .py | """
How to register data with masks from a json file.
Create a list of masks for each image and add to a DatasetVersion.
Define DatasetVersion-level mask-label mapping, which maps RGB values from the mask to class labels.
Notice: This is a custom parser for a specific dataset. Each dataset requires a different parser.... | 138 | 5,420 |
clearml | examples/hyperdatasets/legacy/data-ingestion/dataview_example_singleframe.py | .py | """
How to access and go over data
The general flow:
- Create new dataview.
- Query your dataview.
- Two ways to go over the frames:
- dataview.get_iterator()
- dataview.to_list()
"""
from allegroai import Task, DataView
task = Task.init(project_name="examples", task_name="dataview example")
# simple query
... | 39 | 1,255 |
clearml | examples/hyperdatasets/legacy/data-ingestion/pytorch_dataset_example.py | .py | import numpy as np
import torch.utils.data
from allegroai import DataView, SingleFrame, Task
from PIL import Image
from torch.utils.data import DataLoader
class ExampleDataset(torch.utils.data.Dataset):
def __init__(self, dv):
# automatically adjust dataset to balance all queries
self.frames = dv.... | 52 | 1,322 |
clearml | examples/hyperdatasets/legacy/data-ingestion/pytorch_dataset_example_with_masks.py | .py | import numpy as np
import torch.utils.data
from allegroai import DataView, FrameGroup, Task
from PIL import Image
from torch.utils.data import DataLoader
class ExampleDataset(torch.utils.data.Dataset):
def __init__(self, dv):
# automatically adjust dataset to balance all queries
self.frames = dv.t... | 56 | 1,600 |
clearml | examples/hyperdatasets/legacy/data-ingestion/dataview_example_framegroup.py | .py | from allegroai import Task, DataView
task = Task.init(project_name="examples", task_name="dataview example with masks")
# simple query
dataview = DataView(iteration_order='random')
dataview.set_iteration_parameters(random_seed=123)
dataview.add_query(dataset_name='sample-dataset-masks', version_name='Current')
# p... | 30 | 1,096 |
clearml | examples/storage/upload_and_stream.py | .py | """
Example of uploading files to remote storage and streaming them back to memory
Uploads two small sample files to the given storage location, then reads their contents
back with StorageManager.get_stream() - the content is streamed directly to memory as
bytes chunks, without being written to disk or stored in the l... | 61 | 2,264 |
clearml | examples/services/monitoring/slack_alerts.py | .py | """
Create a ClearML Monitoring Service that posts alerts on Slack Channel groups based on some logic
Creating a new Slack Bot (ClearML Bot):
1. Login to your Slack account
2. Go to https://api.slack.com/apps/new
3. Give the new App a name (For example "ClearML Bot") and select your workspace
4. Press Create App
5. In... | 325 | 12,891 |
clearml | examples/services/cleanup/cleanup_service.py | .py | """
This service will delete archived experiments and their accompanying debug samples, artifacts and models
older than 30 days.
You can configure the run by changing the `args` dictionary:
- delete_threshold_days (float): The earliest day for cleanup.
Only tasks older to this will be ... | 107 | 3,889 |
clearml | examples/services/aws-autoscaler/aws_autoscaler.py | .py | import json
from argparse import ArgumentParser
from collections import defaultdict
from itertools import chain
from pathlib import Path
from typing import Tuple
import yaml
from clearml import Task
from clearml.automation.auto_scaler import AutoScaler, ScalerConfig
from clearml.automation.aws_driver import AWSDriver... | 321 | 11,818 |
clearml | examples/datasets/dataset_creation.py | .py | # Download CIFAR dataset and create a dataset with ClearML's Dataset class
from clearml import StorageManager, Dataset
manager = StorageManager()
dataset_path = manager.get_local_copy(remote_url="https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz")
dataset = Dataset.create(dataset_name="cifar_dataset", dataset_... | 18 | 544 |
clearml | examples/datasets/dataset_folder_syncing.py | .py | import shutil
from uuid import uuid4
from pathlib2 import Path
from clearml import Dataset, StorageManager
def download_mnist_dataset():
manager = StorageManager()
mnist_dataset = Path(
manager.get_local_copy(remote_url="https://allegro-datasets.s3.amazonaws.com/datasets/MNIST.zip", name="MNIST")
... | 53 | 1,591 |
clearml | examples/datasets/data_ingestion.py | .py | # Using ClearML's Dataset class to register data
# Make sure to execute dataset_creation.py first
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision.datasets as datasets
import torchvision.transforms as transforms
from ignite... | 205 | 7,165 |
clearml | examples/datasets/multi_parent_child_dataset.py | .py | from pathlib2 import Path
from clearml import Dataset, StorageManager
def main():
manager = StorageManager()
print("STEP1 : Downloading mnist dataset")
mnist_dataset = Path(
manager.get_local_copy(remote_url="https://allegro-datasets.s3.amazonaws.com/datasets/MNIST.zip", name="MNIST")
)
... | 42 | 1,430 |
clearml | examples/datasets/csv_dataset_creation.py | .py | from clearml import StorageManager, Dataset
def main():
manager = StorageManager()
print("STEP1 : Downloading CSV dataset")
csv_file_path = manager.get_local_copy(
remote_url="https://allegro-datasets.s3.amazonaws.com/datasets/Iris_Species.csv"
)
print("STEP2 : Creating a dataset")
#... | 29 | 901 |
clearml | examples/datasets/single_parent_child_dataset.py | .py | from pathlib2 import Path
from clearml import Dataset, StorageManager
def main():
manager = StorageManager()
print("STEP1 : Downloading mnist dataset")
mnist_dataset = Path(
manager.get_local_copy(remote_url="https://allegro-datasets.s3.amazonaws.com/datasets/MNIST.zip", name="MNIST")
)
... | 35 | 1,166 |
clearml | examples/datasets/urbansounds_dataset_preprocessing.py | .py | import os.path
from pathlib import Path
import matplotlib as mpl
import numpy as np
from tqdm import tqdm
import torchaudio
import torch
from clearml import Task, Dataset
task = Task.init(project_name="examples/Urbansounds", task_name="preprocessing")
# Let's preprocess the data and create a new ClearML dataset from... | 144 | 6,708 |
clearml | examples/datasets/urbansounds_get_data.py | .py | import pandas as pd
from pathlib import Path
from clearml import Task, Dataset, StorageManager
task = Task.init(project_name="examples/Urbansounds", task_name="download data")
configuration = {
"selected_classes": [
"air_conditioner",
"car_horn",
"children_playing",
"dog_bark",
... | 93 | 3,437 |
clearml | examples/automation/manual_random_param_search_example.py | .py | from random import sample
from clearml import Task
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init(
project_name="examples",
task_name="Random Hyper-Parameter Search Example",
task_type=Task.TaskTypes.optimizer,
)
# Create a hyper-paramete... | 76 | 2,397 |
clearml | examples/automation/programmatic_orchestration.py | .py | from clearml import Task
from time import sleep
# Initialize the Task Pipe's first Task used to start the Task Pipe
task = Task.init(
"examples", "Simple Controller Task", task_type=Task.TaskTypes.controller
)
# Create a hyper-parameter dictionary for the task
param = dict()
# Connect the hyper-parameter dictiona... | 50 | 1,852 |
clearml | examples/automation/toy_base_task.py | .py | # This Task is the base task that we will be executing as a second step (see task_piping.py)
# In order to make sure this experiment is registered in the platform, you must execute it once.
from clearml import Task
# Initialize the task pipe's first task used to start the task pipe
task = Task.init('examples', 'Toy B... | 20 | 675 |
clearml | examples/scheduler/cron_example.py | .py | from clearml import Task
from clearml.automation import TaskScheduler
def simple_function():
print('This code is executed in a background thread, '
'on the same machine as the TaskScheduler process')
# add some logic here
print('done')
# Create the scheduler controller
scheduler = TaskSchedule... | 62 | 2,341 |
clearml | examples/scheduler/trigger_example.py | .py | from clearml import Task, Dataset, Model
from clearml.automation import TriggerScheduler
def trigger_model_func(model_id):
model = Model(model_id=model_id)
print(f'model id {model.id} modified')
def trigger_dataset_func(dataset_id):
dataset = Dataset.get(dataset_id=dataset_id)
print(f'dataset id {da... | 66 | 2,190 |
clearml | examples/pipeline/step2_data_processing.py | .py | import pickle
from clearml import Task, StorageManager
from sklearn.model_selection import train_test_split
# Connecting ClearML with the current process,
# from here on everything is logged automatically
task = Task.init(project_name="examples", task_name="Pipeline step 2 process dataset")
# program arguments
# Use... | 57 | 1,806 |
clearml | examples/pipeline/step1_dataset_artifact.py | .py | from clearml import Task, StorageManager
# create an dataset experiment
task = Task.init(project_name="examples", task_name="Pipeline step 1 dataset artifact")
# only create the task, we will actually execute it later
task.execute_remotely()
# simulate local dataset, download one, so we have something local
local_ir... | 20 | 659 |
clearml | examples/pipeline/pipeline_from_functions.py | .py | from clearml import PipelineController
# We will use the following function an independent pipeline component step
# notice all package imports inside the function will be automatically logged as
# required packages for the pipeline execution step
def step_one(pickle_data_url):
# make sure we have scikit-learn fo... | 104 | 4,098 |
clearml | examples/pipeline/decorated_pipeline_step_functions.py | .py | from clearml import PipelineController
def our_decorator(func):
def function_wrapper(*args, **kwargs):
return func(*args, **kwargs) + 1
return function_wrapper
@our_decorator
def step():
return 1
def evaluate(step_return):
assert step_return == 2
if __name__ == "__main__":
pipeline =... | 28 | 695 |
clearml | examples/pipeline/full_tabular_data_process_pipeline_example.py | .py | from clearml import PipelineDecorator, Task
@PipelineDecorator.component(cache=True)
def create_dataset(source_url: str, project: str, dataset_name: str) -> str:
print("starting create_dataset")
from clearml import StorageManager, Dataset
import pandas as pd
local_file = StorageManager.get_local_copy(... | 185 | 6,248 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.