configurator | A Python library for handling configuration files | Configuration Management library
kandi X-RAY | configurator Summary
kandi X-RAY | configurator Summary
A Python library for handling configuration files.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create a config instance from a given prefix
- Return a new source
- Returns an iterator over the dictionary
- Parse a text segment
- Wraps the given value into a ConfigNode
- Create a new instance of this operator
- Convert source to callable
- Ensure all values are in the given dictionary
- Append the end of the sequence
- Create an instance from a file
- Parse a stream from a stream
- Ensure that the value is in the given dictionary
- Inserts at index
- Set value
- Merge two dicts
- Create a merge operation
- Create an instance from text
- Set value at given position
configurator Key Features
configurator Examples and Code Snippets
Community Discussions
Trending Discussions on configurator
QUESTION
We are trying to merge daily (CSV) extract files into our Data Warehouse.
In our use case the DAG's python code is the same for all of our DAGs (~2000), so we generate them by a DAG generator logic from a single python file. In our DAGs we only have 15 tasks (5 dummy tasks, 2 CloudDataFusionStartPipelineOperator tasks, 8 python tasks).
During the DAG generation process we read Airflow Variables (~30-50) to determine what DAGs to generate (this also determines the IDs of the DAGs and the schema/table names they should handle). We call these Generator Variables.
During the DAG generation process the DAGs also read their configuration by their IDs (2-3 more Airflow Variables per generated DAG). We call these Configurator Variables.
Unfortunately in our DAGs we have to handle some passed arguments (via REST API) and lots of dynamically calculated information between the tasks so we rely on the XCOM functionality of the Airflow. This means tremendous number of reads in Airflow's DB.
Where is possible we use user defined macros to configure the tasks to delay the execution of the database reads (the executions of XCOM pulls) until the Task is executed, but it still puts a heavy load on Airflow (Google Cloud Composer). Approximately 50 pulls from XCOM.
Questions:
- Is Airflow's Database designed for this high number of reads (of Airflow Variables and mainly values from XCOM)?
- How should we redesign our code if there is a high number of dynamically calculated fields and metadata we have to pass between the tasks?
- Should we simply accept the fact that there is a heavy load on DB in this type of use case and simply scale the DB up vertically?
XCOM pull example:
...ANSWER
Answered 2022-Apr-10 at 06:43Is Airflow's Database designed for this high number of reads (of Airflow Variables and mainly values from XCOM)?
Yes but the code you shared is abusive. You are using Variable.get()
in top level code. This means that everytime the .py
file is parsed Airflow execute a Variable.get()
which open a session to the DB. Assuming you didn't change the defaults (min_file_process_interval) it means that every 30 seconds you execute a Variable.get()
per each DAG.
To put it into numbers you mentioned that you have 2000 DAGs each one makes ~30-50 Variable.get()
calls this means that you have a range of 6000-10000 calls to the database every 30 seconds. This is very abusive.
If you wish to use to use variables in top level code you should use environment variables and not Airflow variables. This is explained in Dynamic DAGs with environment variables doc.
Noting that Airflow offers the option of defining a custom Secret Backend.
How should we redesign our code if there is a high number of dynamically calculated fields and metadata we have to pass between the tasks?
Airflow can handle high volumes. The issue is more with how you wrote the DAG.Should there are concerns about Xcom table or should you prefer to store it somewhere else Airflow support custom Xcom backend.
Should we simply accept the fact that there is a heavy load on DB in this type of use case and simply scale the DB up vertically?
From your description there are things you can do to improve the situation. Airflow is tested against high volumes of dags and tasks (vertical scale and horizontal scale). If you found evidence of performance issue you can report it with opening a Github Issue to the project. I
QUESTION
I want to load a log4j2 XML configuration programmatically.
My config file is ok and the following two approaches work. One, rename it to log4j2.xml and put it in the classpath (but I have multiple so this was for experiment). Two, do this (which works, but I'm maintaining some older code and would rather try and keep their mechanisms intact)
...ANSWER
Answered 2022-Mar-30 at 12:17Configurator.initialize
only works before the LoggerContext
is created.
It should work in the static block were you set the log4j2.configurationFile
property. If for some reason you need before loading the configuration file, you need to use Configurator.reconfigure
.
QUESTION
I am trying to load log4j2.xml or properties file from a specific location which will be provided at runtime. This is part of a migration from log4j 1.x to log4j 2.x version. I have seen there are lots of changes in the logging configuration loading sequences in log4j2. So right now after searching I have the following methods below -
1 -
...ANSWER
Answered 2022-Mar-26 at 11:00If no LoggerContext
is associated with the caller, all these methods have the same effect: they create a LoggerContext
and configure it using the configuration source provided.
The 4 methods start to differ if there is a LoggerContext
associated with the caller. This can happen if any LogManager
's get*
method was called before (e.g. in a static initializer). If this happens, the first two methods will replace that context's configuration, while the last two are no-ops.
PropertyConfigurator
and DOMConfigurator
in Log4j 1.x worked differently: unless you used log4j.reset=true
key they modified the previous configuration. Although the two classes have been ported to the newest log4j-1.2-api
, the "reset" semantic is not implemented and they behave like Configurator.reconfigure
restricted to a single configuration format.
Remark: Configurator.reconfigure
tries to guess the configuration format to choose the appropriate ConfigurationFactory
. Since both Log4j 2.x and Log4j 1.x have the properties and XML formats, all properties and XML files will interpreted as native Log4j2 configuration files. Check this question for a workaround.
QUESTION
At runtime in my application, I'd like to specify the location of the log4j configuration file dynamically.
This is so that rather than this being a resource bundled in the JAR, it's an actual file on disk that can be edited if there is a problem to increase logging levels.
When using log4j v1.2, you can use DOMConfigurator.configure(URL) to do this.
But now I've upgraded to log4j-slf4j-impl / log4j v2, this method no longer exists.
I can see how to configure log4j directly, but I want to use the existing slf4j compatible XML file without having to change it.
Can anyone help?
...ANSWER
Answered 2022-Feb-19 at 16:39Log4j 2.x uses a ConfigurationFactory
to parse a configuration file. There is a factory for each format and a default factory. The default factory tries to guess the correct format from the file extension of the file: unfortunately both the old Log4j 1.2 and the new Log4j 2.x formats have an .xml
extension, so additional configuration is needed.
In order to parse the Log4j 1.2 XML format you need to add the log4j-1.2.api
artifact and replace the default factory:
QUESTION
I am tring to convert my .jar project into a native image since I need to run it in a device where Java is not supported. For that I installed GraalVM and all the required dependencies, and the native-image build works perfectly (or at least, seems to, as it doesn't give out any errors during the proccess).
The command that I'm using for the build is:
/usr/lib/jvm/graalvm/bin/native-image -jar MyApp.jar MyApp --enable-http --enable-https --no-fallback -H:+ReportExceptionStackTraces
The problem is, when I try to run the native file, I get an exception saying that the log4j class could not be found, and thus I have no application logs during execution:
...ANSWER
Answered 2022-Feb-16 at 18:12Funnily enough, soon after posting this question, I found the answer to it. It had to do with the reflect configuration of the GraalVM. The fix was actually quite simple:
First you run your jar using a special GraalVM option:
QUESTION
I have a project in Eclipse which uses OptaPlanner (v8.12.0). I want to be able to write temporary debug statements within the OptaPlanner code itself, so I:
- cloned the repo,
- checked out branch
8.12.x
, - built using
mvn
, - imported as a pre-existing Maven project
optaplanner-core
(again, Eclipse), and - removed the
optaplanner-core
dependency from my Gradle dependencies
Everything compiles and runs just fine, but OptaPlanner no longer responds to my log config changes.
We're using Log4j2 and, when pulling OptaPlanner using the standard build process (Gradle), I can set the log level just fine using the Log4j2 config. But, with the src as a project dependency, it's not working.
I have tried:
- Including a local
logback.xml
- Adding adding as a vm arg:
-Dlogging.level.org.optaplanner=trace
- Adding adding as a vm arg:
-Dlog4j.configurationFile=C:\path\to\log4j2.xml
- Setting an environment variable
LOGGING_CONFIG=C:\path\to\logback.xml
- Setting the level programmatically using
Configurator
ANSWER
Answered 2022-Jan-31 at 15:42OptaPlanner only has Logback as a scoped-to-test dependency.
To get a local copy of OptaPlanner to pick up your log config, you need to (locally) add your logging dependency to the OptaPlanner buildpath.
For me, this meant adding a Log4j2 dependency to the OptaPlanner pom.xml
:
QUESTION
I want to define deeply nested compositions of applicative functors. For example something like this:
...ANSWER
Answered 2021-Oct-28 at 21:36To make this easier to reason about, first manually desugar fooPhases
each way:
QUESTION
I have a device running TwinCAT/BSD.
Following section 5 the manual for TwinCAT/BSD I have successfully managed to install the TF6250 package. After updating the firewall rules I have confirmed that I am able connect and issue modbus tcp requests successfully using the Default Configuration from section 4.3 of the TF6250 manual.
My project requires mapping that is different from the default (i.e to the %Q registers rather than %M). Normally (when not not using TwinCAT/BSD) I would be able to edit my mapping via the Modbus TCP Configurator, but there does not appear to be an equivalent tool contained in the package for TwinCAT/BSD.
I have tried copying the mapping files that I would have created in the configurator into the Server directory with no luck. Are you able to tell me how my mapping can be updated in the TwinCAT/BSD environment?
If relevant:
- TwinCAT Build: 3.1.4024.19
- TC/BSD: 12.2.9.1,2
- TF6250-Modbus-TCP: 2.0.1.0_1
- pkg repo: https://tcbsd.beckhoff.com/TCBSD/12/stable/packages
ANSWER
Answered 2021-Oct-26 at 03:48I spoke with Beckhoff support who told that TF6250 expects the xml file with the configuration here: /usr/local/etc/TwinCAT/Functions/TF6250-Modbus-TCP/TcModbusSrv.xml
I tested this and it appears to work so all you need to do;
- Create the mapping file as per normal (e.g using the windows tool) and copy the file there.
- Reboot the device to load the configuration from the file.
QUESTION
hi i override the webpack of the create-react-app, in a separate override-webpack.ts file.
What i do is:
- bundle the js files and copy them into
build/static/js
- bundle the css files and copy them into
build/static/css
- **copy the /assets/img folder and copy them into
build/static/media
**NOT all the images from assets
folder are copied.The ones that are used into react components, are ignored, like so:
Context:
So all the js & css files are correctly bundled.
My issue is that the images(png,svg) from the src/assets/img
are copied into build/static/media
, are only the ones that are used into the scss
files, and NOT from whithin my react components, these images are ignored, (as i show above), and that is what i looking for, how to include them also in the build folder
my override-webpack.ts is like this:.
...ANSWER
Answered 2021-Oct-21 at 08:37The problem is, that you are not importing the used images in React but just linking to them. Try importing and using image files like so:
QUESTION
I have this code:
...ANSWER
Answered 2021-Jul-10 at 12:12[Edit]: Using TimeSpan will allow you to specify the precision of your period, but you will lose the ability to have "yesterday" or "tomorrow", and it omits the " ago" or " from now", all of which are localized. A partial workaround would be to use the TimeSpan.Humanize method for TimeSpans less than 366 days and DateTime.Humanize otherwise. And if it's only going to be used in one language, the user can append the appropriate text depending on if the timespan is negative.
You can use the precision parameter with a TimeSpan:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
Install configurator
You can use configurator like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page