Skip to content

Commit db579a6

Browse files
committed
Merge #11: Library docs improvements
Approved-by: rlycx Priority: Normal Auto-deploy: false
2 parents e9f6d6a + ad71a98 commit db579a6

File tree

21 files changed

+134
-118
lines changed

21 files changed

+134
-118
lines changed

default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ let
1212
pytest
1313
pytest-random-order
1414
pytest-parallel
15+
pytest-timeout
1516

1617
# Repeated here so MyPy sees them:
1718
cbor2

libs/opsqueue_python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "opsqueue_python"
3-
version = "0.30.5"
3+
version = "0.30.6"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

libs/opsqueue_python/src/common.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl Chunk {
232232
#[pymethods]
233233
impl Chunk {
234234
fn __repr__(&self) -> String {
235-
format!("{:?}", self)
235+
format!("{self:?}")
236236
}
237237
}
238238

@@ -261,14 +261,14 @@ impl ChunkFailed {
261261
#[pymethods]
262262
impl ChunkFailed {
263263
fn __repr__(&self) -> String {
264-
format!("{:?}", self)
264+
format!("{self:?}")
265265
}
266266
}
267267

268268
#[pymethods]
269269
impl Strategy {
270270
fn __repr__(&self) -> String {
271-
format!("{:?}", self)
271+
format!("{self:?}")
272272
}
273273
}
274274

@@ -365,7 +365,7 @@ impl Submission {
365365
#[pymethods]
366366
impl SubmissionStatus {
367367
fn __repr__(&self) -> String {
368-
format!("{:?}", self)
368+
format!("{self:?}")
369369
}
370370
}
371371

@@ -476,17 +476,17 @@ pub fn start_runtime() -> Arc<tokio::runtime::Runtime> {
476476
///
477477
/// Internally acquires the GIL!
478478
///
479-
/// c.f. https://pyo3.rs/main/doc/pyo3/types/trait.pytracebackmethods
479+
/// c.f. <https://pyo3.rs/main/doc/pyo3/types/trait.pytracebackmethods>
480480
pub fn format_pyerr(err: &PyErr) -> String {
481481
Python::with_gil(|py| {
482482
let msg: Option<String> = (|| {
483483
let traceback = err.traceback(py)?;
484484
let traceback_str = traceback
485485
.format()
486486
.expect("Tracebacks are always formattable");
487-
let str = format!("{}{}", traceback_str, err);
487+
let str = format!("{traceback_str}{err}");
488488
Some(str)
489489
})();
490-
msg.unwrap_or_else(|| format!("{}", err))
490+
msg.unwrap_or_else(|| format!("{err}"))
491491
})
492492
}

libs/opsqueue_python/src/consumer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ impl ConsumerClient {
5151
/// :param object_store_url: The URL used to upload/download objects from e.g. GCS.
5252
/// use `file:///tmp/my/local/path` to use a local file when running small examples in development.
5353
/// use `gs://bucket-name/path/inside/bucket` to connect to GCS in production.
54-
/// Supports the formats listed here: https://docs.rs/object_store/0.11.1/object_store/enum.ObjectStoreScheme.html#method.parse
54+
/// Supports the formats listed here: <https://docs.rs/object_store/0.11.1/object_store/enum.ObjectStoreScheme.html#method.parse>
5555
/// :param object_store_options: A list of key-value strings as extra options for the chosen object store.
56-
/// For example, for GCS, see https://docs.rs/object_store/0.11.2/object_store/gcp/enum.GoogleConfigKey.html#variants
56+
/// For example, for GCS, see <https://docs.rs/object_store/0.11.2/object_store/gcp/enum.GoogleConfigKey.html#variants>
5757
#[new]
5858
#[pyo3(signature = (address, object_store_url, object_store_options=vec![]))]
5959
pub fn new(

libs/opsqueue_python/src/errors.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import_exception!(opsqueue.exceptions, InternalProducerClientError);
3838
/// into PyErr, including those defined in other crates.
3939
///
4040
/// This follows the 'newtype wrapper' approach from
41-
/// https://pyo3.rs/v0.22.5/function/error-handling#foreign-rust-error-types
41+
/// <https://pyo3.rs/v0.22.5/function/error-handling#foreign-rust-error-types>
4242
///
4343
/// The 'C' stands for 'Convertible'.
4444
pub struct CError<T>(pub T);
@@ -52,15 +52,15 @@ impl<T> From<T> for CError<T> {
5252
/// into PyErr.
5353
///
5454
/// This follows the 'newtype wrapper' approach from
55-
/// https://pyo3.rs/v0.22.5/function/error-handling#foreign-rust-error-types
55+
/// <https://pyo3.rs/v0.22.5/function/error-handling#foreign-rust-error-types>
5656
///
5757
/// The 'C' stands for 'Convertible'.
5858
pub type CPyResult<T, E> = Result<T, CError<E>>;
5959

6060
/// Indicates a 'fatal' PyErr: Any Python exception which is _not_ a subclass of `PyException`.
6161
///
6262
/// These are known as 'fatal' exceptions in Python.
63-
/// c.f. https://docs.python.org/3/tutorial/errors.html#tut-userexceptions
63+
/// c.f. <https://docs.python.org/3/tutorial/errors.html#tut-userexceptions>
6464
///
6565
/// We don't consume/wrap these errors but propagate them,
6666
/// allowing things like KeyboardInterrupt, SystemExit or MemoryError,

libs/opsqueue_python/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@ fn opsqueue_internal(m: &Bound<'_, PyModule>) -> PyResult<()> {
3737
)?;
3838

3939
// Top-level functions
40-
// m.add_function(wrap_pyfunction!(sum_as_string, m)?)?;
4140
Ok(())
4241
}

libs/opsqueue_python/src/producer.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use opsqueue::{
1616
use opsqueue::{
1717
common::{chunk, submission, StrategicMetadataMap},
1818
object_store::{ChunkRetrievalError, ChunkType},
19-
producer::common::ChunkContents,
19+
producer::ChunkContents,
2020
tracing::CarrierMap,
2121
E,
2222
};
@@ -50,9 +50,9 @@ impl ProducerClient {
5050
/// :param object_store_url: The URL used to upload/download objects from e.g. GCS.
5151
/// use `file:///tmp/my/local/path` to use a local file when running small examples in development.
5252
/// use `gs://bucket-name/path/inside/bucket` to connect to GCS in production.
53-
/// Supports the formats listed here: https://docs.rs/object_store/0.11.1/object_store/enum.ObjectStoreScheme.html#method.parse
53+
/// Supports the formats listed here: <https://docs.rs/object_store/0.11.1/object_store/enum.ObjectStoreScheme.html#method.parse>
5454
/// :param object_store_options: A list of key-value strings as extra options for the chosen object store.
55-
/// For example, for GCS, see https://docs.rs/object_store/0.11.2/object_store/gcp/enum.GoogleConfigKey.html#variants
55+
/// For example, for GCS, see <https://docs.rs/object_store/0.11.2/object_store/gcp/enum.GoogleConfigKey.html#variants>
5656
#[new]
5757
#[pyo3(signature = (address, object_store_url, object_store_options=vec![]))]
5858
pub fn new(
@@ -81,7 +81,7 @@ impl ProducerClient {
8181
pub fn __repr__(&self) -> String {
8282
format!(
8383
"<opsqueue_producer.ProducerClient(address={:?}, object_store_url={:?})>",
84-
self.producer_client.endpoint_url,
84+
self.producer_client.base_url(),
8585
self.object_store_client.url()
8686
)
8787
}
@@ -176,7 +176,7 @@ impl ProducerClient {
176176
let strategic_metadata = Default::default();
177177

178178
py.allow_threads(|| {
179-
let submission = opsqueue::producer::common::InsertSubmission {
179+
let submission = opsqueue::producer::InsertSubmission {
180180
chunk_size: chunk_size.map(|n| chunk::ChunkSize(n as i64)),
181181
chunk_contents: ChunkContents::Direct {
182182
contents: chunk_contents,
@@ -235,7 +235,7 @@ impl ProducerClient {
235235
tracing::debug!("Finished uploading to object store. {prefix} contains {chunk_count} chunks");
236236

237237
self.block_unless_interrupted(async move {
238-
let submission = opsqueue::producer::common::InsertSubmission {
238+
let submission = opsqueue::producer::InsertSubmission {
239239
chunk_size: chunk_size.map(chunk::ChunkSize),
240240
chunk_contents: ChunkContents::SeeObjectStorage {
241241
prefix: prefix.clone(),

opsqueue/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "opsqueue"
3-
version = "0.30.5"
3+
version = "0.30.6"
44
edition = "2021"
55
description = "lightweight batch processing queue for heavy loads"
66
repository = "https://github.com/channable/opsqueue"

opsqueue/app/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ fn setup_tracing() -> OtelGuard {
136136
.with_thread_ids(true)
137137
.with_target(true),
138138
)
139-
// .with(MetricsLayer::new(meter_provider.clone()))
140139
.with(tracing_opentelemetry::OpenTelemetryLayer::new(otel_tracer()))
141140
// While we don´t forward traces to Sentry, we do want info and above spans to show up as breadcrumbs
142141
// and error spans to show up as errors

opsqueue/src/common/chunk.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ pub mod db {
546546
) -> sqlx::Result<()> {
547547
const ROWS_PER_QUERY: usize = 1000;
548548

549-
// let start = std::time::Instant::now();
550549
let mut iter = chunks.iter().peekable();
551550
while iter.peek().is_some() {
552551
let query_chunks = iter.by_ref().take(ROWS_PER_QUERY);
@@ -721,7 +720,7 @@ pub mod test {
721720

722721
let mut submission = Submission::new();
723722
submission.chunks_total = u63::new(1).into();
724-
submission.id = Submission::generate_id();
723+
submission.id = SubmissionId::new();
725724
let chunk = Chunk::new(
726725
submission.id,
727726
u63::new(0).into(),

0 commit comments

Comments
 (0)