Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/sdk/api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ Timestamp when the metric was recorded.
### value

```python
value: float
value: float | None
```

Value of the metric.
Expand Down Expand Up @@ -1259,7 +1259,7 @@ Exception details if the run failed.
### id

```python
id: ULID
id: ULID | str
```

Unique identifier for the run.
Expand Down
16 changes: 15 additions & 1 deletion docs/sdk/data_types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ def __init__(
caption: Optional caption for the audio
format: Optional format to use (default is wav for numpy arrays)
"""
if sf is None:
raise ImportError(
"Audio processing requires optional dependencies. "
"Install with: pip install dreadnode[multimodal]"
)
self._data = data
self._sample_rate = sample_rate
self._caption = caption
Expand Down Expand Up @@ -178,6 +183,10 @@ def __init__(
caption: Optional caption for the image
format: Optional format to use when saving (png, jpg, etc.)
"""
if PILImage is None:
raise ImportError(
"Image processing requires PIL (Pillow). Install with: pip install dreadnode[multimodal]"
)
self._data = data
self._mode = mode
self._caption = caption
Expand Down Expand Up @@ -555,8 +564,13 @@ def to_serializable(self) -> tuple[bytes, dict[str, t.Any]]:
return self._process_bytes()
if isinstance(self._data, (np.ndarray, list)):
return self._process_numpy_array()
if isinstance(self._data, VideoClip):
if VideoClip is not None and isinstance(self._data, VideoClip):
return self._process_moviepy_clip()
if VideoClip is None and hasattr(self._data, "write_videofile"):
raise ImportError(
"MoviePy VideoClip detected but moviepy not installed. "
"Install with: pip install dreadnode[multimodal]"
)
raise TypeError(f"Unsupported video data type: {type(self._data)}")
```

Expand Down
68 changes: 34 additions & 34 deletions docs/sdk/main.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,11 @@ prompt and the resulting output.
Example

```python
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
model = SomeModel()
data = SomeData()

run.link_objects(model, data)
dreadnode.link_objects(model, data)
```

**Parameters:**
Expand Down Expand Up @@ -539,11 +539,11 @@ def link_objects(self, origin: t.Any, link: t.Any, **attributes: JsonValue) -> N

Example:
~~~
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
model = SomeModel()
data = SomeData()

run.link_objects(model, data)
dreadnode.link_objects(model, data)
~~~

Args:
Expand Down Expand Up @@ -577,26 +577,26 @@ This method uploads a local file or directory to the artifact storage associated
Log a single file:

```python
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
# Save a file
with open("results.json", "w") as f:
json.dump(results, f)

# Log it as an artifact
run.log_artifact("results.json")
dreadnode.log_artifact("results.json")
```

Log a directory:

```python
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
# Create a directory with model files
os.makedirs("model_output", exist_ok=True)
save_model("model_output/model.pkl")
save_config("model_output/config.yaml")

# Log the entire directory as an artifact
run.log_artifact("model_output")
dreadnode.log_artifact("model_output")
```

**Parameters:**
Expand All @@ -620,25 +620,25 @@ def log_artifact(
Examples:
Log a single file:
~~~
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
# Save a file
with open("results.json", "w") as f:
json.dump(results, f)

# Log it as an artifact
run.log_artifact("results.json")
dreadnode.log_artifact("results.json")
~~~

Log a directory:
~~~
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
# Create a directory with model files
os.makedirs("model_output", exist_ok=True)
save_model("model_output/model.pkl")
save_config("model_output/config.yaml")

# Log the entire directory as an artifact
run.log_artifact("model_output")
dreadnode.log_artifact("model_output")
~~~

Args:
Expand Down Expand Up @@ -813,17 +813,17 @@ They can be used to track performance, resource usage, or other quantitative dat
With a raw value:

```python
with dreadnode.run("my_run") as run:
run.log_metric("accuracy", 0.95, step=10)
run.log_metric("loss", 0.05, step=10, mode="min")
with dreadnode.run("my_run"):
dreadnode.log_metric("accuracy", 0.95, step=10)
dreadnode.log_metric("loss", 0.05, step=10, mode="min")
```

With a Metric object:

```python
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
metric = Metric(0.95, step=10, timestamp=datetime.now(timezone.utc))
run.log_metric("accuracy", metric)
dreadnode.log_metric("accuracy", metric)
```

**Parameters:**
Expand Down Expand Up @@ -904,16 +904,16 @@ def log_metric(
Examples:
With a raw value:
~~~
with dreadnode.run("my_run") as run:
run.log_metric("accuracy", 0.95, step=10)
run.log_metric("loss", 0.05, step=10, mode="min")
with dreadnode.run("my_run"):
dreadnode.log_metric("accuracy", 0.95, step=10)
dreadnode.log_metric("loss", 0.05, step=10, mode="min")
~~~

With a Metric object:
~~~
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
metric = Metric(0.95, step=10, timestamp=datetime.now(timezone.utc))
run.log_metric("accuracy", metric)
dreadnode.log_metric("accuracy", metric)
~~~

Args:
Expand Down Expand Up @@ -1297,8 +1297,8 @@ metadata.
Example

```python
with dreadnode.run("my_run") as run:
run.log_param("param_name", "param_value")
with dreadnode.run("my_run"):
dreadnode.log_param("param_name", "param_value")
```

**Parameters:**
Expand Down Expand Up @@ -1336,8 +1336,8 @@ def log_param(

Example:
~~~
with dreadnode.run("my_run") as run:
run.log_param("param_name", "param_value")
with dreadnode.run("my_run"):
dreadnode.log_param("param_name", "param_value")
~~~

Args:
Expand Down Expand Up @@ -1370,8 +1370,8 @@ metadata.
Example

```python
with dreadnode.run("my_run") as run:
run.log_params(
with dreadnode.run("my_run"):
dreadnode.log_params(
param1="value1",
param2="value2"
)
Expand Down Expand Up @@ -1405,8 +1405,8 @@ def log_params(self, to: ToObject = "run", **params: JsonValue) -> None:

Example:
~~~
with dreadnode.run("my_run") as run:
run.log_params(
with dreadnode.run("my_run"):
dreadnode.log_params(
param1="value1",
param2="value2"
)
Expand Down Expand Up @@ -1861,8 +1861,8 @@ Add one or many tags to the current task or run.
Example

```python
with dreadnode.run("my_run") as run:
run.tag("my_tag")
with dreadnode.run("my_run"):
dreadnode.tag("my_tag")
```

**Parameters:**
Expand All @@ -1888,8 +1888,8 @@ def tag(self, *tag: str, to: ToObject = "task-or-run") -> None:

Example:
~~~
with dreadnode.run("my_run") as run:
run.tag("my_tag")
with dreadnode.run("my_run"):
dreadnode.tag("my_tag")
~~~

Args:
Expand Down
42 changes: 21 additions & 21 deletions dreadnode/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,8 @@ def tag(self, *tag: str, to: ToObject = "task-or-run") -> None:

Example:
```
with dreadnode.run("my_run") as run:
run.tag("my_tag")
with dreadnode.run("my_run"):
dreadnode.tag("my_tag")
```

Args:
Expand Down Expand Up @@ -897,8 +897,8 @@ def log_param(

Example:
```
with dreadnode.run("my_run") as run:
run.log_param("param_name", "param_value")
with dreadnode.run("my_run"):
dreadnode.log_param("param_name", "param_value")
```

Args:
Expand All @@ -921,8 +921,8 @@ def log_params(self, to: ToObject = "run", **params: JsonValue) -> None:

Example:
```
with dreadnode.run("my_run") as run:
run.log_params(
with dreadnode.run("my_run"):
dreadnode.log_params(
param1="value1",
param2="value2"
)
Expand Down Expand Up @@ -964,8 +964,8 @@ def log_metric(

Example:
```
with dreadnode.run("my_run") as run:
run.log_metric("metric_name", 42.0)
with dreadnode.run("my_run"):
dreadnode.log_metric("metric_name", 42.0)
```

Args:
Expand Down Expand Up @@ -1010,8 +1010,8 @@ def log_metric(

Example:
```
with dreadnode.run("my_run") as run:
run.log_metric("metric_name", 42.0)
with dreadnode.run("my_run"):
dreadnode.log_metric("metric_name", 42.0)
```

Args:
Expand Down Expand Up @@ -1056,16 +1056,16 @@ def log_metric(
Examples:
With a raw value:
```
with dreadnode.run("my_run") as run:
run.log_metric("accuracy", 0.95, step=10)
run.log_metric("loss", 0.05, step=10, mode="min")
with dreadnode.run("my_run"):
dreadnode.log_metric("accuracy", 0.95, step=10)
dreadnode.log_metric("loss", 0.05, step=10, mode="min")
```

With a Metric object:
```
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
metric = Metric(0.95, step=10, timestamp=datetime.now(timezone.utc))
run.log_metric("accuracy", metric)
dreadnode.log_metric("accuracy", metric)
```

Args:
Expand Down Expand Up @@ -1293,25 +1293,25 @@ def log_artifact(
Examples:
Log a single file:
```
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
# Save a file
with open("results.json", "w") as f:
json.dump(results, f)

# Log it as an artifact
run.log_artifact("results.json")
dreadnode.log_artifact("results.json")
```

Log a directory:
```
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
# Create a directory with model files
os.makedirs("model_output", exist_ok=True)
save_model("model_output/model.pkl")
save_config("model_output/config.yaml")

# Log the entire directory as an artifact
run.log_artifact("model_output")
dreadnode.log_artifact("model_output")
```

Args:
Expand Down Expand Up @@ -1440,11 +1440,11 @@ def link_objects(self, origin: t.Any, link: t.Any, **attributes: JsonValue) -> N

Example:
```
with dreadnode.run("my_run") as run:
with dreadnode.run("my_run"):
model = SomeModel()
data = SomeData()

run.link_objects(model, data)
dreadnode.link_objects(model, data)
```

Args:
Expand Down
Loading
Loading