Package: yamlres
yamlresRetrieving algorithm component combinations from online (or local) yaml resources.This project extends theyamlprototype with web-based resource fields
and creates a declarative algorithm interface. This can help share algorithms
based on existingPythonlibraries via a continuous deployment pipeline
where you only update web resources. Thus, algorithm declarations
are separated from the update cycles of building components.Development:Emmanouil (Manios) KrasanakisDependencies:pyyaml,wgetLoading yaml from the webyamlresparses normalyamlfiles, but also goes through their fields
in search of strings containing the.yamlfile extension and recursively
replaces such fields from files. Recursive loading throws an exception.
You can reference online web resources to automatically download and parse.For example, you can download and load an onlineyamlresource with
the following code:fromyamlresimportLoaderresource="https://raw.githubusercontent.com/maniospas/yamlres/main/examples/ppr.yaml"specs=Loader().load(resource)You can also access fields within yaml file dicts as if they were loaded objects.
For example, you can access theimportfield of the above file by loading:print(Loader().load(resource+".import"))# {'pg': 'pygrank'}Resource accessing within yamlLet's see now how accessing a resource can look like from within 
a different yaml file. This example will create a variation
of examples/ppr.yaml (you could also use the respective URL
in place of that file name) that references parts of the latter:import:examples/ppr.yaml.importassign:ranker:method:pg.HeatKernelargs:3posteriors:examples/ppr.yaml.assign.posteriorsreturn:posteriorsResource cacheThe above will automatically create a res/ folder at your working 
directory and places downloaded resources in there.
Calling the same resources multiple times will now download them again.
To set a different path to store resources and update them on each run, 
you can call:specs=Loader(path="yourpath/",update=True).load(...)Algorithms from yaml definitionsyamlreslets you share definitions of algorithmic pipelines inyamlformat. These should be appropriate dictionaries and can be loaded in
the form of runnable methods with appropriate keyword arguments per:frompyyamlimportRunneralgorithm=Runner().init(specs)print(algorithm(kwarg1=...,kwarg2=...))The following dictionary fields are allowed in algorithm definitions:definitionsPlace anyyamlanchor definitions here. No additional processing
takes place for these .importThis is a dictionary from aliases to respective libraries. You can use methods
of imported libraries in your definitions. For example, the expressionimport libraryname as libis converted toyamlresformat to the following
snippet and lets you reference methods with the patternlib.methodname:import:lib:librarynameDependency safetyRunning defined algorithms is safe in that it runs only on dependencies that
end users have declared. To fully constraint runs on a predefined set of 
dependencies, you can pass these as a list argument to the runner,
for example as in the following snippet:algorithm=Runner(trust=["pygrank"]).init(specs)assignThis is a dictionary of value assignments. If the assignment
is a dictionary and it has amethodfield, then the respective
method is called based on the optionalargsandkwargsfields. For
example, to call a method and assign the returned value to a
variable, you can call:assign:variablename:method:methodnameargs:[arg1,arg2]kwargs:argname1:argvalue1argname2:argvalue2Variables can be used as inputs to other method calls or be returned
at the end. You can also directly define method calls within
arguments or keyword arguments, though you won't be able to
programmatically override those afterwards.Functional pipelineYou can define a functional pipeline by calling the namesake method,
of the yaml.functional module. This starts from an input and calls
each consequent methodsimport:func:yamlres.functionalassign:output:method:func.pipelineargs:-input-methodname-method:MethodBuilder1-method:MethodBuilder2Method buildersYou can define a method builder by calling the namesake method,
of the yaml.functional module. This starts from a method and
arguments to override, and fills in the required ones later.
Mostly this is used to generate the equivalents of
lambda expressions for methods that require other methods 
as inputs:import:func:yamlres.functionalassign:methodvariation:method:func.builderargs:basemethodkwargs:kwarg1:value1kwarg2:value2output:method:func.pipelineargs:-input-methodvariation# will call basemethod(input, kwarg1=value1, kwarg2=value2)-method:MethodBuilder1-method:MethodBuilder2Programmatically overriding valuesAny arguments you provide to runners override any internal
definitions. For example, you can run the examples/ppr.yaml
file with value alpha=0.9 with the following code snippet:fromyamlresimportLoader,Runnerresource="https://raw.githubusercontent.com/maniospas/yamlres/main/examples/ppr.yaml"specs=Loader().load(resource)algorithm=Runner().init(specs)print(algorithm(priors=...,alpha=0.9))returnThis declares either a single value or a dicitionary of values
to return when your defined algorithm is run.