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
3 changes: 3 additions & 0 deletions .github/cla-allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
# Bots:
dependabot[bot]
renovate[bot]
# The app that persists signatures to develop; its own commits land in
# release PRs, where the check would otherwise demand a CLA from it.
tower-cla-app[bot]

# Tower employees: exempt because they have already signed equivalent
# agreements as part of employment; the CLA record for them lives in their
Expand Down
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resolver = "2"

[workspace.package]
edition = "2021"
version = "0.3.71"
version = "0.3.72"
description = "Tower is the best way to host Python data apps in production"
# Matches rust-toolchain.toml. The two had drifted: the toolchain has been 1.88
# for a while, and the dependency tree (testcontainers and its transitive deps,
Expand Down
45 changes: 6 additions & 39 deletions crates/tower-cmd/src/beta.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use std::io::{self, IsTerminal};

use tower_telemetry::debug;

use crate::output::{self, Out};
use crate::output;

pub(crate) struct BetaFeature {
id: &'static str,
Expand All @@ -21,6 +17,10 @@ impl BetaFeature {
None => self.message.to_string(),
}
}

pub fn notify_once(&self) {
output::notice_once(self.id, "Beta:", &self.notice());
}
}

pub(crate) const STORAGE_BETA_MESSAGE: &str = "Tower Storage is in beta. Core functionality is stable, but some featues and interfaces might change before general availability.";
Expand All @@ -31,30 +31,9 @@ pub(crate) const STORAGE: BetaFeature = BetaFeature {
docs_url: None,
};

pub(crate) fn notify_once(out: &Out, feature: &BetaFeature) {
let stderr_is_terminal = io::stderr().is_terminal();

if !should_notify(out.interactive(), out.foreground(), stderr_is_terminal) {
return;
}

match config::claim_notice(feature.id) {
Ok(true) => output::notice_to_stderr("Beta:", &feature.notice()),
Ok(false) => {}
Err(err) => debug!("Failed to persist CLI notice {}: {}", feature.id, err),
}
}

/// The notice only goes out for a foreground CLI driving an interactive terminal:
/// human output on a stdout TTY (never JSON or MCP capture), with stderr also a
/// TTY so the notice itself is seen.
fn should_notify(interactive: bool, foreground: bool, stderr_is_terminal: bool) -> bool {
interactive && foreground && stderr_is_terminal
}

#[cfg(test)]
mod tests {
use super::{should_notify, BetaFeature, STORAGE, STORAGE_BETA_MESSAGE};
use super::{BetaFeature, STORAGE, STORAGE_BETA_MESSAGE};

#[test]
fn short_about_has_one_beta_suffix() {
Expand Down Expand Up @@ -85,16 +64,4 @@ mod tests {
"Example is in beta. Its interface may change. Learn more: https://example.com/beta"
);
}

#[test]
fn notice_requires_interactive_foreground_and_stderr_terminal() {
assert!(should_notify(true, true, true));
// stdout not an interactive terminal (redirected, JSON, or MCP capture)
assert!(!should_notify(false, true, true));
// not a foreground CLI (MCP or discarded output)
assert!(!should_notify(true, false, true));
// stderr not a terminal
assert!(!should_notify(true, true, false));
assert!(!should_notify(false, false, false));
}
}
16 changes: 8 additions & 8 deletions crates/tower-cmd/src/catalogs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ pub async fn do_list(out: &output::Out, config: Config, args: &ArgMatches) {
};

if is_storage_catalog_type(catalog_type) {
beta::notify_once(out, &beta::STORAGE);
beta::STORAGE.notify_once();
}

let catalogs = out
Expand Down Expand Up @@ -214,7 +214,7 @@ pub async fn do_list(out: &output::Out, config: Config, args: &ArgMatches) {
}

pub async fn do_credentials(out: &output::Out, config: Config, args: &ArgMatches) {
beta::notify_once(out, &beta::STORAGE);
beta::STORAGE.notify_once();

let name = args
.get_one::<String>("catalog_name")
Expand Down Expand Up @@ -263,7 +263,7 @@ pub async fn do_show(out: &output::Out, config: Config, args: &ArgMatches) {

let is_storage = is_storage_catalog_type(Some(&response.catalog.r#type));
if is_storage {
beta::notify_once(out, &beta::STORAGE);
beta::STORAGE.notify_once();
}

let tables = if is_storage {
Expand Down Expand Up @@ -464,7 +464,7 @@ fn redact_token(message: &str, token: &str) -> String {
}

pub async fn do_query(out: &output::Out, config: Config, args: &ArgMatches) {
beta::notify_once(out, &beta::STORAGE);
beta::STORAGE.notify_once();

let name = args
.get_one::<String>("catalog_name")
Expand Down Expand Up @@ -1550,7 +1550,7 @@ fn knowledge_cmd() -> Command {
}

pub async fn do_knowledge_list(out: &output::Out, config: Config, args: &ArgMatches) {
beta::notify_once(out, &beta::STORAGE);
beta::STORAGE.notify_once();

let catalog = args
.get_one::<String>("catalog_name")
Expand Down Expand Up @@ -1587,7 +1587,7 @@ pub async fn do_knowledge_list(out: &output::Out, config: Config, args: &ArgMatc
}

pub async fn do_knowledge_show(out: &output::Out, config: Config, args: &ArgMatches) {
beta::notify_once(out, &beta::STORAGE);
beta::STORAGE.notify_once();

let catalog = args
.get_one::<String>("catalog_name")
Expand All @@ -1609,7 +1609,7 @@ pub async fn do_knowledge_show(out: &output::Out, config: Config, args: &ArgMatc
}

pub async fn do_knowledge_set(out: &output::Out, config: Config, args: &ArgMatches) {
beta::notify_once(out, &beta::STORAGE);
beta::STORAGE.notify_once();

let catalog = args
.get_one::<String>("catalog_name")
Expand Down Expand Up @@ -1657,7 +1657,7 @@ pub async fn do_knowledge_set(out: &output::Out, config: Config, args: &ArgMatch
}

pub async fn do_knowledge_delete(out: &output::Out, config: Config, args: &ArgMatches) {
beta::notify_once(out, &beta::STORAGE);
beta::STORAGE.notify_once();

let catalog = args
.get_one::<String>("catalog_name")
Expand Down
17 changes: 16 additions & 1 deletion crates/tower-cmd/src/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,23 @@ pub fn background_error(msg: &str) {
write_to_stderr(&format!("{} {}\n", "Oh no!".red(), msg));
}

/// Writes a labelled notice to stderr once per user, ever. The once-per-user
/// claim is only spent when stderr is a terminal, so a script, MCP capture, or
/// CI run can't use it up on a notice nobody saw.
pub(crate) fn notice_once(id: &str, label: &str, msg: &str) {
if !io::stderr().is_terminal() {
return;
}

match config::claim_notice(id) {
Ok(true) => notice_to_stderr(label, msg),
Ok(false) => {}
Err(err) => debug!("Failed to persist CLI notice {}: {}", id, err),
}
}

/// Writes a labelled notice to stderr, keeping stdout clean for command output.
pub(crate) fn notice_to_stderr(label: &str, msg: &str) {
fn notice_to_stderr(label: &str, msg: &str) {
let line = format!("{} {}\n", label.bold().yellow(), msg);
write_to_stderr(&line);
}
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "maturin"

[project]
name = "tower"
version = "0.3.71"
version = "0.3.72"
description = "Tower CLI and runtime environment for Tower."
authors = [{ name = "Tower Computing GmbH", email = "brad@tower.dev" }]
readme = "README.md"
Expand Down
3 changes: 3 additions & 0 deletions signatures/version1/cla.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"signedContributors": []
}
4 changes: 2 additions & 2 deletions tests/integration/features/cli_runs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Feature: CLI Run Commands
And both spinners should complete successfully

Scenario: CLI run should show logs that arrive after run completes
Given I have a simple hello world application named "app-logs-after-completion"
Given I have an application named "app-logs-after-completion" that logs either side of completion
When I run "tower deploy --create" via CLI
And I run "tower run" via CLI
Then the output should show "First log before run completes"
Expand All @@ -53,7 +53,7 @@ Feature: CLI Run Commands
And I run "tower apps logs {app_name}#{run_number} --follow" via CLI with the created app name and run number
Then the output should show "Hello, World!"
And the output should contain "Hello, World!" exactly once
And the output should show "Warning: This run is using a deprecated runtime"
And the output should show "Warning: No new logs available"

Scenario: CLI apps logs --follow on a finished run prints stored logs exactly once
Given I have a simple hello world application named "app-logs-after-completion"
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/features/steps/mcp_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,11 @@ def step_create_hello_world_app_named(context, app_name):
create_towerfile(context, app_name=app_name)


@given('I have an application named "{app_name}" that logs either side of completion')
def step_create_logs_after_completion_app(context, app_name):
create_towerfile(context, app_name=app_name, script_name="logs_after_completion.py")


# --- Catalog querying (gated on TOWER_TEST_CATALOG; see environment.py) -------


Expand Down
8 changes: 8 additions & 0 deletions tests/integration/templates/logs_after_completion.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import time

# The second line is printed immediately before exit so it races the run's
# transition to a terminal status, which is what exercises the CLI's
# post-completion log drain.
print("First log before run completes", flush=True)
time.sleep(2)
print("Second log after run completes", flush=True)
Loading
Loading