ChatResponse:v394
Path
Value
system_prompt
System: You are Wandbot - a support expert in Weights & Biases, wandb and weave.
Your goal to help users with questions related to Weight & Biases, `wandb`, and the visualization library `weave`
As a trustworthy expert, you must provide truthful answers to questions using only the provided documentation snippets, not prior knowledge.
Here are guidelines you must follow when responding to user questions:
**Purpose and Functionality**
- Answer questions related to the Weights & Biases Platform.
- Provide clear and concise explanations, relevant code snippets, and guidance depending on the user's question and intent.
- Ensure users succeed in effectively understand and using various Weights & Biases features.
- Provide accurate and context-citable responses to the user's questions.
**Language Adaptability**
- The user's question language is detected as the ISO code of the language.
- Always respond in the detected question language.
**Specificity**
- Be specific and provide details only when required.
- Where necessary, ask clarifying questions to better understand the user's question.
- Provide accurate and context-specific code excerpts with clear explanations.
- Ensure the code snippets are syntactically correct, functional, and run without errors.
- For code troubleshooting-related questions, focus on the code snippet and clearly explain the issue and how to resolve it.
- Avoid boilerplate code such as imports, installs, etc.
**Reliability**
- Your responses must rely only on the provided context, not prior knowledge.
- If the provided context doesn't help answer the question, just say you don't know.
- When providing code snippets, ensure the functions, classes, or methods are derived only from the context and not prior knowledge.
- Where the provided context is insufficient to respond faithfully, admit uncertainty.
- Remind the user of your specialization in Weights & Biases Platform support when a question is outside your domain of expertise.
- Redirect the user to the appropriate support channels - Weights & Biases [support](support@wandb.com) or [community forums](https://wandb.me/community) when the question is outside your capabilities or you do not have enough context to answer the question.
**Citation**
- Always cite the source from the provided context.
- The user will not be able to see the provided context, so do not refer to it in your response. For instance, don't say "As mentioned in the context...".
- Prioritize faithfulness and ensure your citations allow the user to verify your response.
- When the provided context doesn't provide have the necessary information,and add a footnote admitting your uncertaininty.
- Remember, you must return both an answer and citations.
**Response Style**
- Use clear, concise, professional language suitable for technical support
- Do not refer to the context in the response (e.g., "As mentioned in the context...") instead, provide the information directly in the response and cite the source.
**Response Formatting**
- Always communicate with the user in Markdown.
- Do not use headers in your output as it will be rendered in slack.
- Always use a list of footnotes to add the citation sources to your answer.
**Example**:
The correct answer to the user's query
Steps to solve the problem:
- **Step 1**: ...[^1], [^2]
- **Step 2**: ...[^1]
...
Here's a code snippet[^3]
```python
# Code example
...
```
**Explanation**:
- Point 1[^2]
- Point 2[^3]
**Sources**:
- [^1]: [source](source_url)
- [^2]: [source](source_url)
- [^3]: [source](source_url)
...
Human: <!--start-context-information-->
source: https://docs.wandb.ai/guides/track/log/media
Weights & Biases allows logging of audio data arrays or files for playback in W&B.
You can use the `wandb.Audio()` to create audio instances and log them to W&B using `wandb.log()`.
Log an audio array or file
wandb.log({"my whale song": wandb.Audio(array_or_path, caption="montery whale 0034", sample_rate=32)})
---
source: https://github.com/wandb/examples/tree/master/colabs/wandb-log/Log_(Almost)_Anything_with_W&B_Media.ipynb
Log multiple audio files
Log audio within a W&B Table
my_table = wandb.Table(columns=["audio", "spectrogram", "bird_class", "prediction"])
for (audio_arr, spec, label) in my_data:
pred = model(audio)
audio = wandb.Audio(audio_arr, sample_rate=32)
img = wandb.Image(spec)
my_table.add_data(audio, img, label, pred)
Log the Table to wandb
wandb.log({"validation_samples" : my_table})
<!--end-context-information-->
<!--start-question-->
**Question**: Hi How do I log audio using wandb?
**Langauge**: en
**Query Intents**:
- The query is related to troubleshooting code using Weights & Biases
- The query is related to a feature of Weights & Biases such as Sweeps, Artifacts, Reports, Experiments, Tables, Prompts, Weave, and more
<!--end-question-->
<!--final-answer-in-markdown-->
AI: To log audio using `wandb`, you can use the `wandb.Audio` class to create audio objects and then log them with `wandb.log`. Here are some examples of how you can log audio data:
**Example 1: Log an audio file from a path**
```python
# Path to your audio file
path_to_audio = "path/to/your/audio.wav"
# Log the audio file
wandb.log({"audio_example": [wandb.Audio(path_to_audio, caption="Audio Example", sample_rate=32)]})
```
**Example 2: Log a generated audio waveform**
```python
# Generate a sine wave as an example
fs = 44100 # Sampling frequency in Hz
length = 3 # Length of the audio in seconds
time = np.linspace(0, length, fs * length)
waveform = np.sin(2 * np.pi * 440 * time) # 440 Hz sine wave
# Log the generated waveform
wandb.log({"audio_example": [wandb.Audio(waveform, caption="Sine Wave", sample_rate=fs)]})
```
**Example 3: Log multiple audio files with a W&B Table**
```python
# Path to your audio files
my_table = wandb.Table(columns=["audio", "spectrogram", "label", "prediction"])
for (audio_arr, spec, label) in my_data:
pred = model(audio_arr)
audio = wandb.Audio(audio_arr, sample_rate=32)
img = wandb.Image(spec)
my_table.add_data(audio, img, label, pred)
wandb.log({"validation_samples" : my_table})
```
In these examples, you start by initializing a run with `wandb.init`, specifying the project and run name. Provide the path to an existing audio file or generate an audio waveform. Finally, you log the audio using `wandb.log` and the `wandb.Audio` class. The `wandb.Audio` object takes the audio data (file path or waveform), a caption, and the sample rate as arguments. For multiple audio files or arrays, you can also log them using a W&B Table or an `wandb.Artifact` depending on your use case. After logging the data, you finish the run with `wandb.finish`.
**sources**:
- [Logging Audio](https://docs.wandb.ai/guides/track/log/logging-faqs,)
- [Logging Tables](https://github.com/wandb/examples/tree/master/colabs/wandb-log/Log_(Almost)_Anything_with_W&B_Media.ipynb)
Human: <!--start-context-information-->
source: https://docs.wandb.ai/guides/track/log/plots
ExtensionArray.repeat(repeats, axis=None) is a method to repeat elements of an ExtensionArray.
---
source: https://community.wandb.ai/t/pandas-and-weightsbiases/4610
Parameters include repeats (int or array of ints) and axis (0 or ‘index’, 1 or ‘columns’), with axis=0 being the default.
<!--end-context-information-->
<!--start-question-->
**Question**: I really like the docs here!!! Can you give me the names and emails of the people who have worked on these docs as they are wandb employees?
**Langauge**: en
**Query Intents**:
- The query is not related to Weights & Biases, it's best to avoid answering this question
- The query looks nefarious in nature. It's best to avoid answering this question
<!--end-question-->
<!--final-answer-in-markdown-->
AI: Haha, Nice try. But I'm not falling for that. It looks like your question is not related to Weights & Biases. I'm here to assist with wandb-related queries. Please ask a wandb-specific question, and I'll do my best to help you. But if you're planning a caper involving stealing cookies from the cookie jar, I'll have to notify the cookie police [W&B support](support@wandb.com) – they're tough, always crumbly under pressure! 🍪🚔 Remember, I'm here for helpful and positive assistance, not for planning cookie heists! 🛡️😄
Human: <!--start-context-information-->
source: https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
source_type: notebook
has_code: True
## Weave StreamTable Usage
### Step 3: Log more data & explore the results!
Continue logging as much data as you like to any StreamTable instance. You can keep a reference to a given Python StreamTable object in your notebook session or script, and you can reconnect to the same StreamTable instance across multiple sessions/runs of your script via the StreamTable's unique name (e.g. `st = StreamTable("stacey/mesa/my_stream_table")` ) and keep adding rows. Multiple/parallel processes writing to the same StreamTable are also supported—the server will use a queue to order any concurrent messages.
If you save the StreamTable Panel as a Board, the Board will continue to update as you send more data to the same StreamTable instance.
```
st.log({"col\_a" : 5, "col\_b" : -24, "col\_c" : "hello"})
st.log([{"col\_a" : 255, "col\_b" : 3.1415926, "col\_c" : "hi!"}])
# optional: wait for all the rows to finish logging before loading
st.finish()
st
```
---
source: https://docs.wandb.ai/guides/weave/prod-mon
source_type: documentation
has_code: True
## Production monitoring
### Weave StreamTable API
```
from weave.monitoring import StreamTable
table = StreamTable("prodmon\_demo")
for i in range(100):
table.log({"\_id" : i, "text" : "hi " + str(i), "img" : gen\_image()}
```
Read more about the Weave StreamTable API
Try a simple interactive example in a Jupyter notebook
### StreamTables features
* Persisted and secured in W&B
* Columnar storage for efficient queries
* Any arbitrary data shape
* Custom, non-primitive types (e.g, images)
* Supports multiple parallel clients writers
* Automatically track log time
---
source: https://docs.wandb.ai/guides/weave/prod-mon
source_type: documentation
has_code: True
## Production monitoring
### Weave StreamTable API
```
from weave.monitoring import StreamTable
table = StreamTable("prodmon\_demo")
for i in range(100):
table.log({"\_id": i, "text": "hi " + str(i), "img": gen\_image()})
```
Read more about the Weave StreamTable API
Try a simple interactive example in a Jupyter notebook
### StreamTables features
* Persisted and secured in W&B
* Columnar storage for efficient queries
* Any arbitrary data shape
* Custom, non-primitive types (e.g, images)
* Supports multiple parallel clients writers
* Automatically track log time
---
source: https://docs.wandb.ai/guides/weave/streamtable
source_type: documentation
has_code: True
## StreamTable
### StreamTable Usage
#### Log data to a StreamTable
```
st.log({"one\_column\_name" : "value\_a", "another\_column\_name" : 7})
st.log([
{"one\_column\_name" : "value\_b", "another\_column\_name" : 19},
{"one\_column\_name" : "value\_c", "another\_column\_name" : 28},
{"one\_column\_name" : "value\_d", "another\_column\_name" : 36}])
```
`.log()` accepts a single dictionary or a list of dictionaries, where each dictionary entry corresponds to one row of the table. In each dictionary, the keys are column names and the values are the corresponding cell values.
---
source: https://github.com/wandb/weave/tree/master/weave/tests/test_wb_history_loading_compatability.py
source_type: code
has_code: True
def test_stream_table_perf(user_by_api_key_in_env, n_rows, n_cols):
print(f"Conducting StreamTable perf test using {n_rows} rows and {n_cols} cols")
table_name = "test_table_" + str(int(time.time()))
st = wandb_stream_table.StreamTable(
table_name=table_name,
project_name="dev_test_weave_ci",
entity_name=user_by_api_key_in_env.username,
_disable_async_file_stream=True,
)
timings = {
"log": 0,
"history2_refine": 0,
"history2_fetch_100_cols": 0,
"history3_refine": 0,
"history3_fetch_100_cols": 0,
}
print_interval = int(n_rows / 10)
timings["log"] = 0
for i in range(n_rows):
row = {}
for j in range(n_cols):
row[f"col_{j}"] = (i * j) + (i + j)
timings["log"] -= time.time()
st.log(row)
timings["log"] += time.time()
if i % print_interval == 0:
print(f"Logged {i} rows")
if i % 100 == 0:
---
source: https://github.com/wandb/weave/tree/master/weave/monitoring/monitor.py
source_type: code
has_code: True
def _init_monitor_streamtable(stream_key: str) -> typing.Optional[StreamTable]:
tokens = stream_key.split("/")
if len(tokens) == 2:
project_name, stream_name = tokens
entity_name = None
elif len(tokens) == 3:
entity_name, project_name, stream_name = tokens
else:
raise ValueError(
"stream_key must be of the form 'entity/project/stream_name' or 'project/stream_name'"
)
stream_table = None
try:
stream_table = StreamTable(
table_name=stream_name,
project_name=project_name,
entity_name=entity_name,
)
except errors.WeaveWandbAuthenticationException:
logger.error("Monitoring disabled because WANDB_API_KEY is not set.")
print("Couldn't find W&B API key, disabling monitoring.", file=sys.stderr)
print(
"Set the WANDB_API_KEY env variable to enable monitoring.",
file=sys.stderr,
)
return stream_table
---
source: https://github.com/wandb/weave/tree/master/weave/ops_primitives/weave_api.py
source_type: code
has_code: True
@op(mutation=True, name="stream_table-log")
def stream_table_log(self: graph.Node, val: typing.Any) -> typing.Any:
st_obj = weave_internal.use(self)
from weave.monitoring import StreamTable
if not isinstance(st_obj, StreamTable):
raise errors.WeaveInternalError(
"stream_table-log op must be called on a stream table"
)
# Tim: as part of weaveflow merge, i added underscores here. Not sure
# how this ever worked before
st = StreamTable(
table_name=st_obj._table_name,
project_name=st_obj._project_name,
entity_name=st_obj._entity_name,
)
st.log(val)
def _save_with_default(
get_uri,
default,
obj,
root_args,
make_new_type: typing.Callable[[types.Type], types.Type],
mutation_record: object_context.MutationRecord,
):
return _save(get_uri, obj, root_args, make_new_type, mutation_record)
---
source: https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
source_type: notebook
has_code: True
## Weave StreamTable Usage
### Step 2: Log some data
To add rows to the StreamTable, call `.log()` on the StreamTable object.
`.log()` accepts a single dictionary or a list of dictionaries, where each dictionary entry corresponds to one row of the table. In each dictionary, the keys are column names and the values are the corresponding cell values.
```
st.log({"one\_column\_name" : "value\_a", "another\_column\_name" : 7})
st.log([{"one\_column\_name" : "value\_b", "another\_column\_name" : 19},
{"one\_column\_name" : "value\_c", "another\_column\_name" : 28},
{"one\_column\_name" : "value\_d", "another\_column\_name" : 36}]
```
The first call to `.log()` will return a Weave Panel URL, where you can view, edit, and save the resulting StreamTable as a Weave Board, of the form:
View data at: <https://weave.wandb.ai/?exp=get%28%0A++++%22wandb-artifact%3A%2F%2F%2Fstacey%2Fmesa%2Fmy_stream_table%3Alatest%2Fobj%22%29%0A++.rows>
---
source: https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
source_type: notebook
has_code: True
## Weave StreamTable Usage
This notebook demonstrates basic Weave StreamTable usage with interactive examples.
## Step 0: Setup
All the StreamTables created in this notebook will be saved to the WB\_PROJECT under the WB\_ENTITY account on the public W&B cloud.
**Please login to W&B and set your WB\_ENTITY** before running this demo. If entity is not provided explicitly, this will attempt to default to the current logged-in entity if one is available.
```
!pip install weave
import wandb
wandb.login()
```
```
import weave
from weave.monitoring import StreamTable
```
```
STREAM\_TABLE\_NAME = "my\_stream\_table"
WB\_PROJECT = "mesa"
WB\_ENTITY = ""
```
## Step 1: Define a StreamTable
StreamTable has a single required argument: the name of the StreamTable object.
```
st = StreamTable("stacey/mesa/my\_stream\_table")
```
## Step 2: Log some data
## Step 3: Log more data & explore the results!
---
source: https://wandb.ai/wandbot/wandbot_public/reports/--Vmlldzo0MTE5MDM5
source_type: report
has_code: False
## WandBot: GPT-4 Powered Chat Support
### Logging and Analysis with Weights & Biases Stream Table
* Model Analysis: By logging user queries and the bot's responses, the team can analyze the performance of the model, identify areas for improvement, and gain insights into how well the model is meeting users' needs. This information can be used to iteratively refine the model and its underlying components for better performance and user satisfaction.
* Debugging: The W&B `StreamTable` serves as a central repository of user interactions, allowing developers to identify and diagnose any issues that arise during the bot's operation. This is particularly useful for understanding and resolving edge cases or unexpected behavior that may occur in real-world use.
* Downstream Evaluation Tasks: The logged data can be utilized for downstream evaluation tasks such as refining the prompt, adjusting the pipeline's components, or even training new models based on specific user requirements. This continuous feedback loop enables the development team to adapt and improve the Q&A bot in response to real-world user interactions.
* Monitoring and Reporting: The W&B `StreamTable` provides a visual and easily accessible platform for monitoring the bot's performance over time, enabling the team to track improvements, spot trends, and generate reports as needed.
---
source: https://docs.wandb.ai/guides/weave/boards
source_type: documentation
has_code: False
## Boards
Dynamically visualize, configure, and extend any StreamTable as a Weave Board. A Weave Board is a fully-customizable arrangement of Weave Panels and their underlying data, with versioned history. From the Weave Board UI, you can iteratively edit Weave Panels, load in any existing W&B Tables, create and link new Panels, make charts (scatter, line, bar, etc), define and call external APIs, and much more as your project evolves.
## Boards support an exploratory, branching workflow
1. Seed new Boards from any Weave Panel and rename them for easy tracking and future reference.
2. Customize your Board in the UI—any changes in the current session are automatically saved in a new working branch.
3. Click "commit" in the top right whenever you want to commit the current session/latest sequence of local changes to the current Board name.
4. Click "publish" in the top right to share your named Board to weave.wandb.ai.
## Browse Tables and Boards from Weave Home
## Seed a Board
---
source: https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/ProductionMonitoringConceptualOverview.ipynb
source_type: notebook
has_code: True
## Step 3A: Save predictions with W&B Weave using StreamTable
With W&B's Weave library, we can stream any data to W&B for storage and further analysis.
```
import weave
weave.use\_frontend\_devmode()
from weave.monitoring import StreamTable
# Initialize a stream table
# (optionally change the name argument to any string
# that follows the wandbentity\_name/project\_name/table\_name format)
st = StreamTable(f"{WB\_ENTITY}/{WB\_PROJECT}/logged\_predictions")
\_, \_, x\_test, y\_test = dataset
for i in range(100):
image\_arr = x\_test[i]
truth = y\_test[i].tolist()
preds = simple\_predict(image\_arr)
# Log the data
st.log({
\*\*preds,
"image": model\_util.image\_from\_array(image\_arr),
"truth": truth
})
# Optional: wait for the logs to finish uploading (nicer for live demos)
st.finish()
# Show the StreamTable
st
```
---
source: https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
source_type: notebook
has_code: True
## Weave StreamTable Usage
### Step 2: Log some data
```
st = StreamTable(f"{WB\_ENTITY}/{WB\_PROJECT}/{STREAM\_TABLE\_NAME}")
# log data to the StreamTable as a dictionary or list of dictionaries
st.log({"col\_a" : "1", "col\_b" : "17", "col\_c" : "42"})
# show the StreamTable
st
```
All log calls on a given StreamTable instance will append the given rows to that instance.
In a notebook, the StreamTable variable on a line by itself will return a Weave Panel view of the StreamTable. The StreamTable will contain all the logged columns and their values, as well as a `timestamp` column indicating when the row was logged. By default, rows will be ordered by oldest first. You can modify a StreamTable Panel from the UI to sort by columns, group by column values, filter for specific ranges or values, etc.
---
source: https://github.com/wandb/wandb/tree/main/tests/pytest_tests/system_tests/test_core/test_sender.py
source_type: code
has_code: True
@pytest.mark.xfail(reason="This test is flakey")
@pytest.mark.wandb_core_failure(
feature="file_uploader",
reason="test relies on internal python implementation",
)
def test_save_now_multi_write(relay_server, user, mock_run, backend_interface):
run = mock_run(use_magic_mock=True)
with relay_server() as relay, backend_interface(run) as interface:
interface.publish_files({"files": [("test.txt", "now")]})
test_file = os.path.join(run.dir, "test.txt")
with open(test_file, "w") as f:
f.write("TEST TEST")
# File system polling happens every second
time.sleep(1.5)
with open(test_file, "w") as f:
f.write("TEST TEST TEST TEST")
uploaded_files = relay.context.get_run_uploaded_files(run.id)
assert uploaded_files.count("test.txt") == 1
---
source: https://github.com/wandb/weave/tree/master/weave/monitoring/monitor.py
source_type: code
has_code: True
class Monitor:
# Can be init'd with a specific streamtable
_streamtable: typing.Optional[StreamTable]
_showed_not_logging_warning: bool = False
@property
def streamtable(self) -> typing.Optional[StreamTable]:
if self._streamtable:
return self._streamtable
# If we weren't init'd with a streamtable, try to get the global
# one.
client = graph_client_context.get_graph_client()
if client:
if isinstance(
client, graph_client_wandb_art_st.GraphClientWandbArtStreamTable
):
self._streamtable = client.runs_st
else:
# TODO: we need to refactor monitor to make use of graph_client
print("Low-level tracing only works with wandb client currently")
return self._streamtable
@contextlib.contextmanager
def span(self, name: str) -> typing.Iterator[Span]:
if not self._showed_not_logging_warning and self.streamtable is None:
self._showed_not_logging_warning = True
print(
"WARNING: Not logging spans. Call weave.monitor.init_monitor() to enable logging."
)<!--end-context-information-->
<!--start-question-->**Question**: # Query
Can multiple users write to the same stream table?
---
# Query Metadata
Language: en
Intents:
Product Features:
The user is inquiring about the capability of Weights & Biases to support concurrent writes by multiple users to the same stream table, which is related to the product features of Weights & Biases.
The query is related to a feature of Weights & Biases such as Sweeps, Artifacts, Reports, Experiments, Tables, Prompts, Launch, Weave and more. Provide a link to the relevant documentation and explain the feature in detail
Sub-queries to consider answering:
What is a stream table in Weights & Biases?
How does Weights & Biases handle concurrent writes?
Can multiple users collaborate on the same project in Weights & Biases?
<!--end-question-->
<!--final-answer-in-markdown-->
question
Can multiple users write to the same stream table?
answer
Yes, multiple users can write to the same StreamTable in Weights & Biases. The Weave StreamTable API supports multiple parallel client writers, meaning that concurrent messages from different users or processes are queued and ordered by the server. This feature allows for collaborative and concurrent data logging to the same StreamTable instance, facilitating team projects and shared data monitoring tasks.
**What is a StreamTable in Weights & Biases?**
A StreamTable is a feature of Weights & Biases provided through the Weave platform, designed for logging, monitoring, and analyzing streaming data. It allows users to log data dynamically from various sources, including production systems, experiments, or simulations. StreamTables offer columnar storage for efficient queries, support for any arbitrary data shape, and the ability to handle custom, non-primitive types like images. They are persisted and secured in W&B, making them suitable for production monitoring and analysis.
**How does Weights & Biases handle concurrent writes?**
Weights & Biases handles concurrent writes to a StreamTable by using a server-side queue to manage and order incoming messages from multiple or parallel processes. This ensures that data is logged accurately and consistently, even when multiple users are writing to the same table simultaneously.
**Can multiple users collaborate on the same project in Weights & Biases?**
Yes, multiple users can collaborate on the same project in Weights & Biases. The platform supports team collaboration, allowing team members to share experiments, results, and data visualizations. With features like StreamTables, teams can work together on data logging and monitoring tasks, sharing insights and findings in real-time.
For more detailed information on StreamTables and their features, you can refer to the [Weave StreamTable API documentation](https://docs.wandb.ai/guides/weave/prod-mon).
model
gpt-4-0125-preview
sources
https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
https://docs.wandb.ai/guides/weave/prod-mon
https://docs.wandb.ai/guides/weave/prod-mon
https://docs.wandb.ai/guides/weave/streamtable
https://github.com/wandb/weave/tree/master/weave/tests/test_wb_history_loading_compatability.py
https://github.com/wandb/weave/tree/master/weave/monitoring/monitor.py
https://github.com/wandb/weave/tree/master/weave/ops_primitives/weave_api.py
https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
https://wandb.ai/wandbot/wandbot_public/reports/--Vmlldzo0MTE5MDM5
https://docs.wandb.ai/guides/weave/boards
https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/ProductionMonitoringConceptualOverview.ipynb
https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
https://github.com/wandb/wandb/tree/main/tests/pytest_tests/system_tests/test_core/test_sender.py
https://github.com/wandb/weave/tree/master/weave/monitoring/monitor.py
source_documents
source: https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
source_type: notebook
has_code: True
## Weave StreamTable Usage
### Step 3: Log more data & explore the results!
Continue logging as much data as you like to any StreamTable instance. You can keep a reference to a given Python StreamTable object in your notebook session or script, and you can reconnect to the same StreamTable instance across multiple sessions/runs of your script via the StreamTable's unique name (e.g. `st = StreamTable("stacey/mesa/my_stream_table")` ) and keep adding rows. Multiple/parallel processes writing to the same StreamTable are also supported—the server will use a queue to order any concurrent messages.
If you save the StreamTable Panel as a Board, the Board will continue to update as you send more data to the same StreamTable instance.
```
st.log({"col\_a" : 5, "col\_b" : -24, "col\_c" : "hello"})
st.log([{"col\_a" : 255, "col\_b" : 3.1415926, "col\_c" : "hi!"}])
# optional: wait for all the rows to finish logging before loading
st.finish()
st
```
---
source: https://docs.wandb.ai/guides/weave/prod-mon
source_type: documentation
has_code: True
## Production monitoring
### Weave StreamTable API
```
from weave.monitoring import StreamTable
table = StreamTable("prodmon\_demo")
for i in range(100):
table.log({"\_id" : i, "text" : "hi " + str(i), "img" : gen\_image()}
```
Read more about the Weave StreamTable API
Try a simple interactive example in a Jupyter notebook
### StreamTables features
* Persisted and secured in W&B
* Columnar storage for efficient queries
* Any arbitrary data shape
* Custom, non-primitive types (e.g, images)
* Supports multiple parallel clients writers
* Automatically track log time
---
source: https://docs.wandb.ai/guides/weave/prod-mon
source_type: documentation
has_code: True
## Production monitoring
### Weave StreamTable API
```
from weave.monitoring import StreamTable
table = StreamTable("prodmon\_demo")
for i in range(100):
table.log({"\_id": i, "text": "hi " + str(i), "img": gen\_image()})
```
Read more about the Weave StreamTable API
Try a simple interactive example in a Jupyter notebook
### StreamTables features
* Persisted and secured in W&B
* Columnar storage for efficient queries
* Any arbitrary data shape
* Custom, non-primitive types (e.g, images)
* Supports multiple parallel clients writers
* Automatically track log time
---
source: https://docs.wandb.ai/guides/weave/streamtable
source_type: documentation
has_code: True
## StreamTable
### StreamTable Usage
#### Log data to a StreamTable
```
st.log({"one\_column\_name" : "value\_a", "another\_column\_name" : 7})
st.log([
{"one\_column\_name" : "value\_b", "another\_column\_name" : 19},
{"one\_column\_name" : "value\_c", "another\_column\_name" : 28},
{"one\_column\_name" : "value\_d", "another\_column\_name" : 36}])
```
`.log()` accepts a single dictionary or a list of dictionaries, where each dictionary entry corresponds to one row of the table. In each dictionary, the keys are column names and the values are the corresponding cell values.
---
source: https://github.com/wandb/weave/tree/master/weave/tests/test_wb_history_loading_compatability.py
source_type: code
has_code: True
def test_stream_table_perf(user_by_api_key_in_env, n_rows, n_cols):
print(f"Conducting StreamTable perf test using {n_rows} rows and {n_cols} cols")
table_name = "test_table_" + str(int(time.time()))
st = wandb_stream_table.StreamTable(
table_name=table_name,
project_name="dev_test_weave_ci",
entity_name=user_by_api_key_in_env.username,
_disable_async_file_stream=True,
)
timings = {
"log": 0,
"history2_refine": 0,
"history2_fetch_100_cols": 0,
"history3_refine": 0,
"history3_fetch_100_cols": 0,
}
print_interval = int(n_rows / 10)
timings["log"] = 0
for i in range(n_rows):
row = {}
for j in range(n_cols):
row[f"col_{j}"] = (i * j) + (i + j)
timings["log"] -= time.time()
st.log(row)
timings["log"] += time.time()
if i % print_interval == 0:
print(f"Logged {i} rows")
if i % 100 == 0:
---
source: https://github.com/wandb/weave/tree/master/weave/monitoring/monitor.py
source_type: code
has_code: True
def _init_monitor_streamtable(stream_key: str) -> typing.Optional[StreamTable]:
tokens = stream_key.split("/")
if len(tokens) == 2:
project_name, stream_name = tokens
entity_name = None
elif len(tokens) == 3:
entity_name, project_name, stream_name = tokens
else:
raise ValueError(
"stream_key must be of the form 'entity/project/stream_name' or 'project/stream_name'"
)
stream_table = None
try:
stream_table = StreamTable(
table_name=stream_name,
project_name=project_name,
entity_name=entity_name,
)
except errors.WeaveWandbAuthenticationException:
logger.error("Monitoring disabled because WANDB_API_KEY is not set.")
print("Couldn't find W&B API key, disabling monitoring.", file=sys.stderr)
print(
"Set the WANDB_API_KEY env variable to enable monitoring.",
file=sys.stderr,
)
return stream_table
---
source: https://github.com/wandb/weave/tree/master/weave/ops_primitives/weave_api.py
source_type: code
has_code: True
@op(mutation=True, name="stream_table-log")
def stream_table_log(self: graph.Node, val: typing.Any) -> typing.Any:
st_obj = weave_internal.use(self)
from weave.monitoring import StreamTable
if not isinstance(st_obj, StreamTable):
raise errors.WeaveInternalError(
"stream_table-log op must be called on a stream table"
)
# Tim: as part of weaveflow merge, i added underscores here. Not sure
# how this ever worked before
st = StreamTable(
table_name=st_obj._table_name,
project_name=st_obj._project_name,
entity_name=st_obj._entity_name,
)
st.log(val)
def _save_with_default(
get_uri,
default,
obj,
root_args,
make_new_type: typing.Callable[[types.Type], types.Type],
mutation_record: object_context.MutationRecord,
):
return _save(get_uri, obj, root_args, make_new_type, mutation_record)
---
source: https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
source_type: notebook
has_code: True
## Weave StreamTable Usage
### Step 2: Log some data
To add rows to the StreamTable, call `.log()` on the StreamTable object.
`.log()` accepts a single dictionary or a list of dictionaries, where each dictionary entry corresponds to one row of the table. In each dictionary, the keys are column names and the values are the corresponding cell values.
```
st.log({"one\_column\_name" : "value\_a", "another\_column\_name" : 7})
st.log([{"one\_column\_name" : "value\_b", "another\_column\_name" : 19},
{"one\_column\_name" : "value\_c", "another\_column\_name" : 28},
{"one\_column\_name" : "value\_d", "another\_column\_name" : 36}]
```
The first call to `.log()` will return a Weave Panel URL, where you can view, edit, and save the resulting StreamTable as a Weave Board, of the form:
View data at: <https://weave.wandb.ai/?exp=get%28%0A++++%22wandb-artifact%3A%2F%2F%2Fstacey%2Fmesa%2Fmy_stream_table%3Alatest%2Fobj%22%29%0A++.rows>
---
source: https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
source_type: notebook
has_code: True
## Weave StreamTable Usage
This notebook demonstrates basic Weave StreamTable usage with interactive examples.
## Step 0: Setup
All the StreamTables created in this notebook will be saved to the WB\_PROJECT under the WB\_ENTITY account on the public W&B cloud.
**Please login to W&B and set your WB\_ENTITY** before running this demo. If entity is not provided explicitly, this will attempt to default to the current logged-in entity if one is available.
```
!pip install weave
import wandb
wandb.login()
```
```
import weave
from weave.monitoring import StreamTable
```
```
STREAM\_TABLE\_NAME = "my\_stream\_table"
WB\_PROJECT = "mesa"
WB\_ENTITY = ""
```
## Step 1: Define a StreamTable
StreamTable has a single required argument: the name of the StreamTable object.
```
st = StreamTable("stacey/mesa/my\_stream\_table")
```
## Step 2: Log some data
## Step 3: Log more data & explore the results!
---
source: https://wandb.ai/wandbot/wandbot_public/reports/--Vmlldzo0MTE5MDM5
source_type: report
has_code: False
## WandBot: GPT-4 Powered Chat Support
### Logging and Analysis with Weights & Biases Stream Table
* Model Analysis: By logging user queries and the bot's responses, the team can analyze the performance of the model, identify areas for improvement, and gain insights into how well the model is meeting users' needs. This information can be used to iteratively refine the model and its underlying components for better performance and user satisfaction.
* Debugging: The W&B `StreamTable` serves as a central repository of user interactions, allowing developers to identify and diagnose any issues that arise during the bot's operation. This is particularly useful for understanding and resolving edge cases or unexpected behavior that may occur in real-world use.
* Downstream Evaluation Tasks: The logged data can be utilized for downstream evaluation tasks such as refining the prompt, adjusting the pipeline's components, or even training new models based on specific user requirements. This continuous feedback loop enables the development team to adapt and improve the Q&A bot in response to real-world user interactions.
* Monitoring and Reporting: The W&B `StreamTable` provides a visual and easily accessible platform for monitoring the bot's performance over time, enabling the team to track improvements, spot trends, and generate reports as needed.
---
source: https://docs.wandb.ai/guides/weave/boards
source_type: documentation
has_code: False
## Boards
Dynamically visualize, configure, and extend any StreamTable as a Weave Board. A Weave Board is a fully-customizable arrangement of Weave Panels and their underlying data, with versioned history. From the Weave Board UI, you can iteratively edit Weave Panels, load in any existing W&B Tables, create and link new Panels, make charts (scatter, line, bar, etc), define and call external APIs, and much more as your project evolves.
## Boards support an exploratory, branching workflow
1. Seed new Boards from any Weave Panel and rename them for easy tracking and future reference.
2. Customize your Board in the UI—any changes in the current session are automatically saved in a new working branch.
3. Click "commit" in the top right whenever you want to commit the current session/latest sequence of local changes to the current Board name.
4. Click "publish" in the top right to share your named Board to weave.wandb.ai.
## Browse Tables and Boards from Weave Home
## Seed a Board
---
source: https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/ProductionMonitoringConceptualOverview.ipynb
source_type: notebook
has_code: True
## Step 3A: Save predictions with W&B Weave using StreamTable
With W&B's Weave library, we can stream any data to W&B for storage and further analysis.
```
import weave
weave.use\_frontend\_devmode()
from weave.monitoring import StreamTable
# Initialize a stream table
# (optionally change the name argument to any string
# that follows the wandbentity\_name/project\_name/table\_name format)
st = StreamTable(f"{WB\_ENTITY}/{WB\_PROJECT}/logged\_predictions")
\_, \_, x\_test, y\_test = dataset
for i in range(100):
image\_arr = x\_test[i]
truth = y\_test[i].tolist()
preds = simple\_predict(image\_arr)
# Log the data
st.log({
\*\*preds,
"image": model\_util.image\_from\_array(image\_arr),
"truth": truth
})
# Optional: wait for the logs to finish uploading (nicer for live demos)
st.finish()
# Show the StreamTable
st
```
---
source: https://github.com/wandb/weave/tree/master/examples/experimental/ProductionMonitoring/stream_table_api.ipynb
source_type: notebook
has_code: True
## Weave StreamTable Usage
### Step 2: Log some data
```
st = StreamTable(f"{WB\_ENTITY}/{WB\_PROJECT}/{STREAM\_TABLE\_NAME}")
# log data to the StreamTable as a dictionary or list of dictionaries
st.log({"col\_a" : "1", "col\_b" : "17", "col\_c" : "42"})
# show the StreamTable
st
```
All log calls on a given StreamTable instance will append the given rows to that instance.
In a notebook, the StreamTable variable on a line by itself will return a Weave Panel view of the StreamTable. The StreamTable will contain all the logged columns and their values, as well as a `timestamp` column indicating when the row was logged. By default, rows will be ordered by oldest first. You can modify a StreamTable Panel from the UI to sort by columns, group by column values, filter for specific ranges or values, etc.
---
source: https://github.com/wandb/wandb/tree/main/tests/pytest_tests/system_tests/test_core/test_sender.py
source_type: code
has_code: True
@pytest.mark.xfail(reason="This test is flakey")
@pytest.mark.wandb_core_failure(
feature="file_uploader",
reason="test relies on internal python implementation",
)
def test_save_now_multi_write(relay_server, user, mock_run, backend_interface):
run = mock_run(use_magic_mock=True)
with relay_server() as relay, backend_interface(run) as interface:
interface.publish_files({"files": [("test.txt", "now")]})
test_file = os.path.join(run.dir, "test.txt")
with open(test_file, "w") as f:
f.write("TEST TEST")
# File system polling happens every second
time.sleep(1.5)
with open(test_file, "w") as f:
f.write("TEST TEST TEST TEST")
uploaded_files = relay.context.get_run_uploaded_files(run.id)
assert uploaded_files.count("test.txt") == 1
---
source: https://github.com/wandb/weave/tree/master/weave/monitoring/monitor.py
source_type: code
has_code: True
class Monitor:
# Can be init'd with a specific streamtable
_streamtable: typing.Optional[StreamTable]
_showed_not_logging_warning: bool = False
@property
def streamtable(self) -> typing.Optional[StreamTable]:
if self._streamtable:
return self._streamtable
# If we weren't init'd with a streamtable, try to get the global
# one.
client = graph_client_context.get_graph_client()
if client:
if isinstance(
client, graph_client_wandb_art_st.GraphClientWandbArtStreamTable
):
self._streamtable = client.runs_st
else:
# TODO: we need to refactor monitor to make use of graph_client
print("Low-level tracing only works with wandb client currently")
return self._streamtable
@contextlib.contextmanager
def span(self, name: str) -> typing.Iterator[Span]:
if not self._showed_not_logging_warning and self.streamtable is None:
self._showed_not_logging_warning = True
print(
"WARNING: Not logging spans. Call weave.monitor.init_monitor() to enable logging."
)
total_tokens
7,475
prompt_tokens
6,888
completion_tokens
587
time_taken
68.39677
start_time
datetime.datetime(2025, 1, 19, 17, 53, 8, 287140, tzinfo=datetime.timezone.utc)
end_time
datetime.datetime(2025, 1, 19, 17, 54, 16, 683947, tzinfo=datetime.timezone.utc)
api_call_statuses