Comment by bavaza on Conflicting names in Python namespace plugins
@sinoroc - tried it, but if the name of the plugin folder is the same (i.e. instead of plugin1, plugin2 you have my_plugin), the init.py file inside it gets overwritten.
View ArticleComment by bavaza on How to use JWT in case of UI application is using SSO
If you need to generate JWT's, why not have the client explicitly call an endpoint for this (regardless if and how they were logged in)?
View ArticleComment by bavaza on C++ default keyword and default constructor
see here: stackoverflow.com/questions/21164641/…, or here: stackoverflow.com/questions/20828907/…
View ArticleComment by bavaza on How to get csv rows as array with Python csv?
see here: stackoverflow.com/a/3387212/499721
View ArticleComment by bavaza on Wrong result when comparing ref and WeakMethod in Python?
@chepner rephrased so both the issue and the motivations are (hopefully) clear.
View ArticleComment by bavaza on Wrong result when comparing ref and WeakMethod in Python?
Thanks @chepner. To me it seems a quirk in WeakMethod: even though id(x) != id(y), both x == y and WeakMethod(x) == WeakMethod(y) are true, which makes sense. However, altough cb != cb.methodm we still...
View ArticleComment by bavaza on Configuring request model per endpoint in FastAPI
Thank @Rafael-WO, but this is exactly what I'm trying to avoid (assume I have 50 endpoints, not 3). BTW, if I were to use inheritance, I think you could just override the Config class in each mode,...
View ArticleComment by bavaza on Parsing non-standard date element using xmlschema
@DarkKnight you are right, but in this case I can safely assume it is YYYY/mm/dd
View ArticleComment by bavaza on Programmatically adding commands to `fakeredis` in Python
@Mate - yes, I've installed the correct package. The problem is that fakeredis does not support 'command info', which is called by JsonModel
View ArticleComment by bavaza on Cannot unpickle an instance of a class which inherits...
@ThierryLathuille - done
View Articlecopy --from in docker-compose multi-stage build
I have a Docker file which build a react application, and then runs an nginx server to serve the resulting webpack. I use a multi-stage build, something like:# Dockerfile# build applicationFROM...
View ArticleAnswer by bavaza for Script error while serving react app from a subdirectory
Indeed, the problem was with nginx configuration, not with React. I was missing a directive to tell nginx to ignore the 'app' part of the URL, and to load files from a different directory. Doing the...
View ArticleScript error while serving react app from a subdirectory
I'm trying to serve a react application (created using craco) from a subdirectory (https://my-domain/app). Following the steps of this guide, and modifying nginx config's location to /app, I do get the...
View ArticleC# Parse string to type known at runtime
I have a file holding some of the variables of a class, and each line is a pair : variable, value. I'm looking for a way to load these at runtime (a-la XmlSerializer), using reflection.Is there a way...
View ArticleAccept gzipped body in FastAPI / Uvicorn
I'm using FastAPI with Uvicorn to implement a u-service which accepts a json payload in the request's body. Since the request body can be quite large, I wish the service to accept gzipped. How do I...
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 ArticleAnswer by bavaza for python dynamic value in api payload
You should escape the curly braces in the formatted string, like so:f'[{{"code": "orderno", "value":"{valuetarget}"}}]'But why not let requests format the string for you?import requestsurl =...
View ArticleAnswer by bavaza for Tensorflow Serving: no versions of servable...
Had the same thing on Windows 10. I finally:Noticed that I forgot to clone the tensorflow/serving repository to my local machineRan on Ubuntu-wsl-2 console, as using Windows command line, I could...
View Articlepy.test hangs after showing test results
I'm using py.test to run a bunch of tests. The tests seem to pass, but the process never terminates:===== test session starts =====platform win32 -- Python 2.7.3 -- pytest-2.3.4collected 179...
View ArticleAnswer by bavaza for How to get csv rows as array with Python csv?
Short answer:with open('zumatchende.csv') as f: cf = csv.reader(f) row = [e[0] for e in cf] rowOut[14]: ['a', 'b', 'c', 'd']Long answer:Per the docs, DictReader outputs a dictionary whose keys are...
View ArticleShould I inherit the class logger when using NLog?
When logging from a derived class, should I inherit the class-logger instance from the base class, or instantiate a new one? Namely, which is better:public class Base{ private static Logger _logger =...
View ArticleEmbedding a Python interpreter in a multi-threaded C++ program with pybind11
I'm trying to use pybind11 in order to make a 3rd party C++ library call a Python method. The library is multithreaded, and each thread creates a Python object, and then does numerous calls to the...
View ArticleCompiler error for exhaustive switch
Why do I get a "not all code paths return a value", for VeryBoolToBool() in the following code? public enum VeryBool { VeryTrue, VeryFalse };public bool VeryBoolToBool(VeryBool veryBool){...
View ArticleAnswer by bavaza for Transformation of dates in pandas dataframe to the...
Note that pd.to_datetime() returns a pd.Timestamp object. You then use str(timestamp), which defaults to an ISO format string. You can use you <timestamp>.strftime() instead, and get a different...
View ArticleConfiguring request model per endpoint in FastAPI
I have a FastAPI application, in which several endpoints require the same input model, but in each, some attributes may be optional while others are required. For example:# file:...
View ArticleARM Cortex toolchain speed optimization
There is an abundance of IDEs and toolchains for the Arm Cortex architecture for C/C++.Lately, faced with a hard speed optimization issue on my STM Cortex-M3, I started wondering if there are indeed...
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 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 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 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 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 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 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 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 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 Article
More Pages to Explore .....