Package: zensols.util
Zensols UtilitiesCommand line, configuration and persistence utilities generally used for any
more than basic application.  This general purpose library is small, has few
dependencies, and helpful across many applications.See thefull documentation.Paper onarXiv.Some features include:AHydraorJava Springlike application level support forconfigurationthanconfigparser.Construct objects using configuration files (both INI and YAML).Parse primitives, dictionaries, file system objects, instances of classes.Acommand action libraryusing an action mnemonic to invocation of a
handler that is integrated with a the configuration API.  This supports long
and short GNU style options as provided byoptparse.Streamline in memory and on diskpersistence.Multi-processing work with apersistence layer.A secondary goal of the API is to make prototyping Python code quick and easy
using the REPL.  Examples include reloading modules in theconfiguration
factory.DocumentationFull documentationConfiguration: powerful but
simple configuration system much likeHydraorJava SpringCommand line:
automagically creates a fully functional command with help from a PythondataclassPersistence: cache
intermediate data(structures) to the file systemAPI referenceObtainingThe easiest way to install the command line program is via thepipinstaller:pip3installzensols.utilCommand Line UsageThis library contains a full persistence layer and other utilities.  However, a
quick and dirty example that uses the configuration and command line
functionality is given below.  See the otherexamplesto learn how else to
use it.fromdataclassesimportdataclassfromenumimportEnum,autoimportosfromioimportStringIOfromzensols.cliimportCliHarnessCONFIG="""# configure the command line[cli]apps = list: app# define the application, whose code is given below[app]class_name = fsinfo.Application"""classFormat(Enum):short=auto()long=auto()@dataclassclassApplication(object):"""Toy application example that provides file system information."""defls(self,format:Format=Format.short):"""List the contents of the directory.:param format: the output format"""cmd=['ls']ifformat==Format.long:cmd.append('-l')os.system(' '.join(cmd))if(__name__=='__main__'):harnes=CliHarness(app_config_resource=StringIO(CONFIG))harnes.run()The framework automatically links each command line action mnemonic (i.e.ls)
to the data classApplicationmethodlsand command line help.  For
example:$python./fsinfo.py-h
Usage:fsinfo.py[options]:

Listthecontentsofthedirectory.

Options:-h,--helpshowthishelpmessageandexit--versionshowtheprogramversionandexit-f,--format<long|short>shorttheoutputformat

$python./fsinfo.py-fshort
__pycache__fsinfo.pySee thefull examplethat demonstrates more complex command line handling,
documentation and explanation.TemplateThe easiest to get started is totemplateout this project is to create your
own boilerplate project with themkprojutility.  This requires aJava
installation, and easy to create a Python boilerplate with the following
commands:# clone the boilerplate repogitclonehttps://github.com/plandes/template# download the boilerplate toolwgethttps://github.com/plandes/clj-mkproj/releases/download/v0.0.7/mkproj.jar# create a python template and build it outjava-jarmkproj.jarconfig-stemplate/python
java-jarmkproj.jarThis creates a project customized with your organization's name, author, and
other details about the project.  In addition, it also creates a sample
configuration file and command line that is ready to be invoked by either a
Python REPL or from the command line viaGNU make.If you don't want to bother installing this program, the following sections
have generated code as examples from which you can copy/paste.CitationIf you use this project in your research please use the following BibTeX entry:@inproceedings{landes-etal-2023-deepzensols,title="{D}eep{Z}ensols: A Deep Learning Natural Language Processing Framework for Experimentation and Reproducibility",author="Landes, Paul  andDi Eugenio, Barbara  andCaragea, Cornelia",editor="Tan, Liling  andMilajevs, Dmitrijs  andChauhan, Geeticka  andGwinnup, Jeremy  andRippeth, Elijah",booktitle="Proceedings of the 3rd Workshop for Natural Language Processing Open Source Software (NLP-OSS 2023)",month=dec,year="2023",address="Singapore, Singapore",publisher="Empirical Methods in Natural Language Processing",url="https://aclanthology.org/2023.nlposs-1.16",pages="141--146"}ChangelogAn extensive changelog is availablehere.LicenseMIT LicenseCopyright (c) 2020 - 2023 Paul Landes