automagic | web automated test platform with Python Django | Functional Testing library
kandi X-RAY | automagic Summary
kandi X-RAY | automagic Summary
web automated test platform with Python Django
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of automagic
automagic Key Features
automagic Examples and Code Snippets
Community Discussions
Trending Discussions on automagic
QUESTION
Is there a way to combine two structs struct A
and struct B
into a third struct C
in a way that changes to either struct A
or struct B
, like adding a new field, are automagically reflected in struct C
?
The motivation is that e.g. struct A
comes from some library and struct B
and is under my control and contains additional data not found in struct A
; the purpose of struct C
is to access the members of struct A
and struct B
via a uniform interface represented by struct C
.
pseudocode:
...ANSWER
Answered 2021-Jun-11 at 19:26In short - base C does not have support for this without macro trickery or libraries
If you are open to the two - you could use something homegrown like this:
QUESTION
I am going to write my own FORTH "engine" in GNU assembler (GAS) for Linux x86-64 (specifically for AMD Ryzen 9 3900X that is siting on my table).
(If it will be success, I may use similar idea for make firmware for retro 6502 and similar home-brewed computer)
I want to add some interesting debugging features, as saving comments with the compiled code in for of "NOP words" with attached strings, which would do nothing in runtime, but when disassembling/printing out already defined words it would print those comment too, so it would not loose all the headers ( a b -- c) and comments like ( here goes this particular little trick ) and I would be able try to define new words with documentation, and later print all definitions in some nice way and make new library from those, which I consider good. (And have switch to just ignore comments for "production release")
I had read too much of optimalization here and I am not able to understand all of that in few weeks, so I will put out microoptimalisation until it will suffer performance problems and then I will start with profiling.
But I want to start with at least decent architectural decisions.
What I understood yet:
- it would be nice, if the programs was run mainly from CPU cache, not from memory
- the cache is filled somehow "automagically", but having related data/code compact and as near as possible may help a lot
- I identified some areas, that would be good candidates for caching and some, that are not so good - I sorted it in order of importance:
- assembler code - the engine and basic words like "+" - used all the time (fixed size, .text section)
- both stacks - also used all the time (dynamic, I will probably use rsp for data stack and implement return stack independly - not sure yet, which will be "native" and which "emulated")
- forth bytecode - the defined and compiled words - used at runtime, when the speed matters (still growing size)
- variables, constants, strings, other memory allocations (used in runtime)
- names of words ("DUP", "DROP" - used only when defining new words in compilation phase)
- comments (used one daily or so)
As there is lot of "heaps" that grows up (well, there is not "free" used, so it may be also stack, or stack growing up) (and two stacks that grows down) I am unsure how to implement it, so the CPU cache will cover it somehow decently.
My idea is to use one "big heap" (and increse it with brk() when needed), and then allocate big chunks of alligned memory on it, implementing "smaller heaps" in each chunk and extend them to another big chunk when the old one is filled up.
I hope, that the cache would automagically get the most used blocks first keep it most of the time and the less used blocks would be mostly ignored by the cache (respective it would occupy only small parts and get read and kicked out all the time), but maybe I did not it correctly.
But maybe is there some better strategy for that?
...ANSWER
Answered 2021-Jun-04 at 23:53Your first stops for further reading should probably be:
- What Every Programmer Should Know About Memory? re: cache
- https://agner.org/optimize/ re: everything else about writing efficient asm.
- https://uops.info/ for a better version of Agner Fog's instruction tables.
- See also other links in https://stackoverflow.com/tags/x86/info
so I will put out microoptimalisation until it will suffer performance problems and then I will start with profiling.
Yes, probably good to start trying stuff so you have something to profile with HW performance counters, so you can correlate what you're reading about performance stuff with what actually happens. And so you get some ideas of possible details you hadn't thought of yet before you go too far into optimizing your overall design idea. You can learn a lot about asm micro-optimization by starting with something very small scale, like a single loop somewhere without any complicated branching.
Since modern CPUs use split L1i and L1d caches and first-level TLBs, it's not a good idea to place code and data next to each other. (Especially not read-write data; self-modifying code is handled by flushing the whole pipeline on any store too near any code that's in-flight anywhere in the pipeline.)
Related: Why do Compilers put data inside .text(code) section of the PE and ELF files and how does the CPU distinguish between data and code? - they don't, only obfuscated x86 programs do that. (ARM code does sometimes mix code/data because PC-relative loads have limited range on ARM.)
Yes, making sure all your data allocations are nearby should be good for TLB locality. Hardware normally uses a pseudo-LRU allocation/eviction algorithm which generally does a good job at keeping hot data in cache, and it's generally not worth trying to manually clflushopt
anything to help it. Software prefetch is also rarely useful, especially in linear traversal of arrays. It can sometimes be worth it if you know where you'll want to access quite a few instructions later, but the CPU couldn't predict that easily.
AMD's L3 cache may use adaptive replacement like Intel does, to try to keep more lines that get reused, not letting them get evicted as easily by lines that tend not to get reused. But Zen2's 512kiB L2 is relatively big by Forth standards; you probably won't have a significant amount of L2 cache misses. (And out-of-order exec can do a lot to hide L1 miss / L2 hit. And even hide some of the latency of an L3 hit.) Contemporary Intel CPUs typically use 256k L2 caches; if you're cache-blocking for generic modern x86, 128kiB is a good choice of block size to assume you can write and then loop over again while getting L2 hits.
The L1i and L1d caches (32k each), and even uop cache (up to 4096 uops, about 1 or 2 per instruction), on a modern x86 like Zen2 (https://en.wikichip.org/wiki/amd/microarchitectures/zen_2#Architecture) or Skylake, are pretty large compared to a Forth implementation; probably everything will hit in L1 cache most of the time, and certainly L2. Yes, code locality is generally good, but with more L2 cache than the whole memory of a typical 6502, you really don't have much to worry about :P
Of more concern for an interpreter is branch prediction, but fortunately Zen2 (and Intel since Haswell) have TAGE predictors that do well at learning patterns of indirect branches even with one "grand central dispatch" branch: Branch Prediction and the Performance of Interpreters - Don’t Trust Folklore
QUESTION
I have an API that returns 100 rows of lots of different json data including HTTP Status:
...ANSWER
Answered 2021-May-30 at 17:43I believe an array.reduce
loop will do the trick.
QUESTION
I am trying to create a pie chart in a jupyter notebook with Bokeh that can be updated with a slider. I have a custom function that creates data
from a pre-existing dataframe. I would like the slider to manipulate input f
to that function, such that data
is different when displayed in the pie graph. Here is an example:
ANSWER
Answered 2021-May-26 at 22:13You need to implement your data_generator
function as well as the angle calculation entirely in your JavaScript callback. It is not clear what you are trying to achieve with your code but here is some example JS callback implementation based on your code that changes the pie angle (tested with Bokeh v2.1.1):
QUESTION
I am sorry, the functional programming "loops" got me a bit in of head scratching about purrr
.
I know that to use own, non-vectorised functions one can use map_chr()
and I used it together with mutate
to produce 2 new columns. But at one point I did not understand if map_chr every time takes the whole column and produces list output every time or just takes the one value and places that one computed output value in the new variable. Basically - if for every variable in the SHASUM
column the map_chr returns just one value, or a list of values from which the correct value is automagically picked? I am sorry the question is so fuzzy, but I found it hard to understand, not knowing what is going on inside pipes
and mutate
.
My example code below.
Is this a valid/correct use of map_chr() (and more generally map functions from purrr) or is there something better that I should have done?
...ANSWER
Answered 2021-May-16 at 08:52map_chr
is a hidden loop. The benefit of using it is the code can be piped/chained together and it is better for readability.
map_chr(SHASUM,getlongLink,y=longLinkBase)
is same as doing -
QUESTION
So creating effectively hashable dataclasses with frozen=True
is great, but it breaks some of my ability to typecheck code I write since mypy doesn't seem to automagically recognize frozen dataclasses as instances of Hashable
. This makes sense of course, since I haven't explicitly extended that class (it would be amazing if it could infer), but has anyone out there found an elegant solution/workaround for this issue?
ANSWER
Answered 2021-May-11 at 18:34Looking deeper my issue was actually a variance issue due to working with lists of such dataclasses. The support is there, just be mindful of variance 👍🏽 :)
In my cases using Sequence[Hashable]
instead of List[Hashable]
in my type annotations appeased mypy. Turns out that since list elements are mutable they are invariant whereas sequences are covariant. See https://mypy.readthedocs.io/en/stable/common_issues.html#invariance-vs-covariance
QUESTION
I have an YAML Github Action script, which consists on three jobs. The nightly script should check if there are any user commits (which are not coming from an automatic jobs) and then perform nightly release build and deploy the build to the testing environment.
I am struggling with using one single point where I could skip the execution of the whole second and the third jobs if there are no recent commits in the repositories others than autocommits.
As far as I understand, I should either fail the script to skip any further actions or set the if
condition to every step of every job I have, which doesn't look concise.
I tried to put the if
condition on the job itself, but it does not work. The job executes even if the if
condition value is false. Is there any better or elegant solution other to fail the job if repository is stale?
ANSWER
Answered 2021-May-11 at 14:18According to the documentation:
When you use expressions in an if conditional, you may omit the expression syntax (${{ }}) because GitHub automatically evaluates the if conditional as an expression, unless the expression contains any operators. If the expression contains any operators, the expression must be contained within ${{ }} to explicitly mark it for evaluation.
That means your if must be defined as:
QUESTION
QUESTION
Using Make how do I run a command for every directory that contains a file matching *.csproj but does not including a file matching *.Test.csproj using pure make.
SCENARIO
I have previously used Fake and Rake extensively but this is my first time using Make to do anything over and above the simple use of dumb targets.
I have a simple makefile that compiles a .net core solution, runs some tests and then packages up a nuget package. Here is a simplified example.
...ANSWER
Answered 2021-May-07 at 19:06Make implements standard globbing as defined by POSIX. It doesn't provide advanced globbing as implemented in some advanced shells like zsh (or bash if you enable it).
So, **
is identical *
; there's no globbing character that means "search in all subdirectories". If you want to do that you need to use find
.
Also, in make a pattern is a template that can match some target that you specifically want to build. It's not a way to find targets. And pattern rules only are pattern rules if the target contains the pattern character %
; putting a %
in a prerequisite of an explicit target doesn't do anything, make treats it as if it were just a %
character.
so:
QUESTION
Heyya,
We recently went through with upgrading all our projects from .NET Core 3.0 to 3.1, as well as most of the associated NuGet packages. The projects themselves are hosted as services and function-apps on portal.azure.com, and is transferred via a Bitbucket repository (pushed up from development, pulled down automagically by Azure).
This worked great for two out of three services, but the last one have proved to be difficult. The service itself is working fine, and it's (seemingly) doing what it should when testing it via localhost, but the associated Function-app is throwing "System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0>'. The system cannot find the file specified." at us.
After some investigating, it would seem there was no Microsoft.Extensions.Logging.Abstractions package installed at all according to our NuGet Manager, but it was still being used by ILogger
in the code (explanations for this one are very welcome). Nevertheless, we forced a downgrade to Microsoft.Extensions.Logging.Abstractions version 3.1.10, tested the application via localhost before deploying it, and this time we got the exact same error message, thrown in Program.cs
. Guessing this wouldn't make things better even if we tried pushing it up.
The target version of the function-app is ~3
(only ~3
and ~1
is available, not ~2
), and it has worked prior to this. The AzureFunctionVersion (available in the project's configuration files) is v3
. Re-creating the function-app on the Portal does not seem to have made any difference.
ANSWER
Answered 2021-Apr-30 at 18:32This usually happens when a Nuget package version is used by different nuget packages internally and is incompatible for at least one of them.
It means, there is a Nuget package in your project which requires Microsoft.Extensions.Logging.Abstractions
version 5.0.0.0
, but Azure Function latest version as of now installs version 2.1.1
.
So, the solution is to upgrade Microsoft.Extensions.Logging.Abstractions
version to 5.0.0.0
as SDK supports > 2.1.1
:
OR
downgrade the dependent nuget package so that it uses 2.1.1
(or whichever version is installed in your project)
QUESTION
first of all I am not familiar with javascript but I saw the easy way azure search generator offers a portal with search features and I used it to make a search portal for more than 100K files. Everything is fine except that I'm facing the same issue of the limit of 5 facets mentionned in this old post (Facet count in Azure cognitive search (Automagic)). Using search explorer I can see the request url needed (example : facet=category,count:10 / https://xxxxxsearch.search.windows.net/indexes/azureblob-index/docs?api-version=2020-06-30-Preview&search=*&facet=category%2Ccount%3A10) but can't figure out where to put this in search app hmtl page or how I can parse it to automagic to consider this.
thank you Gaurav for your feedback. no, that part is clear for me. Please let me show an example of what I want to achieve.I generated a search a portal using AzSearchGenerator and for this sample I have 7 files with the same metadata key but with 7 differents values (blob-content-files). I am seeking a way to override the limit of 5 checkboxfacets in the search portal generated (check here : portal-search-generated). Is there a way to change this by including the request url with count parameter higher than 5 checkboxes (storage-explorer-request ) to update the automagic instance in the html code (automagic-intialization-html).
Could you please advice me how I can complete this.
...ANSWER
Answered 2021-Apr-20 at 14:15If I understand correctly, you're looking for a way to specify facet
parameter in Search Explorer in Azure Portal.
Simply add &facet=category,count:10
in the Query string field and that should do the trick. For example, see the screenshot below.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install automagic
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