FastAPI schema from an OpenAPI YAML file
I'm looking for a way to initialize a FastAPI server with an existing OpenAPI YAML schema file.The docs do describe how to modify the auto-generated schema, but I'm looking for something like...
View ArticleDynamically set path in target cointaier when saving files using...
I'm using SQLAlchemy file along with SQLModel to manage files on AZURE_BLOB storage. This works fine, but all the files gets saved in the top-level of the Azure Storage container, regardless of the...
View ArticleStoring response as json in Python requests-cache
I'm using requests-cache to cache http responses in human-readable format.I've patched requests using the filesystem backend, and the the serializer to json, like so:import...
View ArticleHow to set-up liveness and readiness probes for Dramatiq worker pods [closed]
I want to set-up liveness and readiness probes for Dramatiq worker pods. By default, the workers do not run an http server, not listen to TCP connections, so defining a health/readiness http endpoints...
View ArticleObfuscating timestamps in UUID v7
UUID7 is a type of time-ordered UUID, which compared to UUID4:Does not degrade performance when used as primary keys in databases (e.g. this benchmark).Includes its creation timestamp, which makes...
View ArticleAnswer by bavaza for Exclude fields from a pydantic class
Facing a similar issue, I ended up with (Pydantic 2):from typing import Any, Annotatedfrom pydantic import BaseModel, Field, AfterValidatorfrom pydantic.json_schema import SkipJsonSchemaExcludedField =...
View ArticleWhat functions are passed to the Promise when awaiting in javascript?
Consider the following code, which awaits a Promise:async function handleSubmit() { try { await submitForm(answer); } catch (err) { console.log('Error') }}function submitForm(answer) { return new...
View ArticleComment by bavaza on What functions are passed to the Promise when awaiting...
That's exactly my question. I did not explicitly pass any functions as resolve/reject, yet they get passed, or the code will not work.
View ArticleComment by bavaza on What functions are passed to the Promise when awaiting...
The Promise constructor get a 2-parameter function as its input. Someone has to pass them when evaluating the (resolved or rejected) function. Is this some magic performed by the await machinery?
View Articleembedded C - using "volatile" to assert consistency
Consider the following code:// In the interrupt handler file:volatile uint32_t gSampleIndex = 0; // declared 'extern'void HandleSomeIrq(){ gSampleIndex++;}// In some other filevoid Process(){ uint32_t...
View ArticleComment by bavaza on Require a number of fractional decimal places with an...
AFAIK, anchors (^/$) are not supported in XSD. This code causes erroneous validation errors in Python's xmlschema library. See w3.org/XML/2008/03/xsdl-regex/re.xml#id2.
View ArticleHow do you mock patch a python class and get a new Mock object for each...
OK,I know this is mentioned in the manual, and probably has to do with side_effect and/or return_value, but a simple, direct example will help me immensely. I have: class ClassToPatch(): def...
View ArticleEmbed git commit hash in a .NET dll
I'm building a C# application, using Git as my version control.Is there a way to automatically embed the last commit hash in the executable when I build my application?For example, printing the commit...
View ArticleCannot unpickle an instance of a class which inherits from `time`
Consider the following class, which inherits from datetime.time:class TimeWithAddSub(time): _date_base = date(2000, 1, 1) def __new__(cls, hour=0, minute=0, second=0, microsecond=0, tzinfo=None): obj =...
View ArticleIs there a way to change gunicorn log level at runtime?
I have a FastApi service running on Gunicorn server in a K8s pod. Is there a way to change the log levels / settings at runtime, without restarting the server?
View ArticleMust I call atomic load/store explicitly?
C++11 introduced the std::atomic<> template library. The standard specifies the store() and load() operations to atomically set / get a variable shared by more than one thread.My question is: are...
View ArticleAnswer by bavaza for Remove an open file if an error occurs
Here's a handy context manager I sometimes use. It has the benefit of still raising the exception, while deleting partial files:from contextlib import contextmanagerfrom pathlib import...
View Article@patch decorator cannot set Provider
I tried patching a provider class by decorating a test method with @patch:class TestMyUnit(unittest.TestCase):...@patch(provider.Provider,autospec=True)def test_init(self, mock_provider): passHowever,...
View ArticleAnswer by bavaza for Is it possible to re-throw an error in the calling...
Here's what I ended up doing. As far as I can tell, this is the only way to leave the ReactiveX pipe, and let the surrounding code handle the error. Would be happy if someone has a more elegant...
View ArticleIs it possible to re-throw an error in the calling method in RxAndroid?
Inspired by .Net TPL, I'm trying to find a way to handle an error outside the RX pipe. Specifically, on error, I wish the Observer pipe to stop, and pass control back to the surrounding method....
View Article