Skip to content

feat: more logging, default to false #684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 14, 2025
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
8 changes: 3 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bytes = "1.7"
chrono = "0.4.39"
clap = "4.5"
cql2 = "0.3.0"
duckdb = "=1.2.0"
duckdb = "1.2.1"
fluent-uri = "0.3.2"
futures = "0.3.31"
geo = "0.29.3"
Expand All @@ -53,7 +53,7 @@ geoarrow = "0.4.0-beta.4"
geojson = "0.24.1"
http = "1.1"
jsonschema = { version = "0.29.0", default-features = false }
libduckdb-sys = "=1.2.0"
libduckdb-sys = "1.2.1"
log = "0.4.25"
mime = "0.3.17"
mockito = "1.5"
Expand All @@ -78,7 +78,7 @@ stac-server = { version = "0.3.2", path = "crates/server" }
syn = "2.0"
tempfile = "3.16"
thiserror = "2.0"
tokio = "1.43"
tokio = "1.44"
tokio-postgres = "0.7.12"
tokio-postgres-rustls = "0.13.0"
tokio-stream = "0.1.16"
Expand All @@ -94,6 +94,4 @@ url = "2.3"
webpki-roots = "0.26.8"

[patch.crates-io]
duckdb = { git = "https://github.com/duckdb/duckdb-rs", rev = "5eeb1f01c278790ce1e2d24045f0096e9e2528e4" }
libduckdb-sys = { git = "https://github.com/duckdb/duckdb-rs", rev = "5eeb1f01c278790ce1e2d24045f0096e9e2528e4" }
geoarrow = { git = "https://github.com/geoarrow/geoarrow-rs/", rev = "2cd0d623e4b9f1ac3bc5ff6563ccce689a47c641" }
4 changes: 4 additions & 0 deletions crates/cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use stac_server::Backend;
use std::{collections::HashMap, io::Write, str::FromStr};
use tokio::{io::AsyncReadExt, net::TcpListener, runtime::Handle};
use tracing::metadata::Level;
use tracing_subscriber::EnvFilter;

const DEFAULT_COLLECTION_ID: &str = "default-collection-id";

Expand Down Expand Up @@ -263,7 +264,10 @@ impl Stacrs {
pub async fn run(self, init_tracing_subscriber: bool) -> Result<()> {
if init_tracing_subscriber {
tracing_subscriber::fmt()
.with_env_filter(EnvFilter::from_default_env())
.with_max_level(self.log_level())
.with_writer(std::io::stderr)
.pretty()
.init();
}
match self.command {
Expand Down
1 change: 1 addition & 0 deletions crates/duckdb/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Conditionally disable parsing the WKB ([#635](https://github.com/stac-utils/stac-rs/pull/635))
- `Client.extensions` ([#665](https://github.com/stac-utils/stac-rs/pull/665))
- `Config.install_extensions` ([#681](https://github.com/stac-utils/stac-rs/pull/681))
- `Config.from_href` ([#684](https://github.com/stac-utils/stac-rs/pull/684))

### Removed

Expand Down
38 changes: 34 additions & 4 deletions crates/duckdb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ pub fn search(
} else {
search.limit = None;
};
let client = Client::new()?;
let config = Config::from_href(href);
let client = Client::with_config(config)?;
client.search_to_json(href, search)
}

Expand Down Expand Up @@ -163,6 +164,26 @@ pub struct Extension {
pub installed_from: Option<String>,
}

impl Config {
/// Creates a configuration from an href.
///
/// Use this to, e.g., autodetect s3 urls.
///
/// # Examples
///
/// ```
/// use stac_duckdb::Config;
/// let config = Config::from_href("s3://bucket/item.json");
/// assert!(config.use_s3_credential_chain);
/// ```
pub fn from_href(s: &str) -> Config {
Config {
use_s3_credential_chain: s.starts_with("s3://"),
..Default::default()
}
}
}

impl Client {
/// Creates a new client with no data sources.
///
Expand Down Expand Up @@ -199,33 +220,42 @@ impl Client {
pub fn with_config(config: Config) -> Result<Client> {
let connection = Connection::open_in_memory()?;
if let Some(ref custom_extension_repository) = config.custom_extension_repository {
log::debug!("setting custom extension repository: {custom_extension_repository}");
connection.execute(
"SET custom_extension_repository = ?",
[custom_extension_repository],
)?;
}
if let Some(ref extension_directory) = config.extension_directory {
log::debug!("setting extension directory: {extension_directory}");
connection.execute("SET extension_directory = ?", [extension_directory])?;
}
if config.install_extensions {
log::debug!("installing spatial");
connection.execute("INSTALL spatial", [])?;
log::debug!("installing icu");
connection.execute("INSTALL icu", [])?;
}
connection.execute("LOAD spatial", [])?;
connection.execute("LOAD icu", [])?;
if config.use_httpfs && config.install_extensions {
log::debug!("installing httpfs");
connection.execute("INSTALL httpfs", [])?;
}
if config.use_s3_credential_chain {
if config.install_extensions {
log::debug!("installing aws");
connection.execute("INSTALL aws", [])?;
}
log::debug!("creating s3 secret");
connection.execute("CREATE SECRET (TYPE S3, PROVIDER CREDENTIAL_CHAIN)", [])?;
}
if config.use_azure_credential_chain {
if config.install_extensions {
log::debug!("installing azure");
connection.execute("INSTALL azure", [])?;
}
log::debug!("creating azure secret");
connection.execute("CREATE SECRET (TYPE azure, PROVIDER CREDENTIAL_CHAIN)", [])?;
}
Ok(Client { connection, config })
Expand Down Expand Up @@ -566,9 +596,9 @@ impl Default for Config {
Config {
use_hive_partitioning: false,
convert_wkb: true,
use_s3_credential_chain: true,
use_azure_credential_chain: true,
use_httpfs: true,
use_s3_credential_chain: false,
use_azure_credential_chain: false,
use_httpfs: false,
install_extensions: true,
custom_extension_repository: None,
extension_directory: None,
Expand Down
Loading