Skip to content

Commit

Permalink
update all doc to stable version 2.5.2, except for jp version
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name committed Aug 24, 2024
1 parent 74766c6 commit 2ab2740
Show file tree
Hide file tree
Showing 119 changed files with 9,731 additions and 167 deletions.
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Project description
#### easy_configer version : 2.5.1
#### easy_configer version : 2.5.2
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/HuangChiEn/easy_config/main.yaml?branch=master&event=push&style=for-the-badge&label=unittest&color=green)

![easy-configer logo](https://raw.githubusercontent.com/HuangChiEn/easy_config/master/assets/logo.png)
Expand Down Expand Up @@ -45,7 +45,7 @@ That leverage me to package my solution for solving this issue. The easy_config

5. **Support the absl style FLAGS functionality (declare once, use anywhere)**

And, of course the following attribute is supported :
And, of course the following attributes are supported :

* dot-access of any config argument (even in nested dictionary)

Expand All @@ -60,6 +60,7 @@ And, of course the following attribute is supported :
---

### Newly update features 🚀
0. Easy-configer pass all test-case, and v2.5.2 is the stable version.
1. Integrate argument intepolation with using ${cfg} notation
2. Integrate enviroment variable intepolation with using ${cfg} notation

Expand Down Expand Up @@ -236,7 +237,7 @@ There have two kind of way to prepare the arguments in easy-config : we can eith
lr = 1e-4
sched = 'cos_anneal'

#### We have defined the config file, now let's see how to access any agruments! Execute `python quick_hier.py` in work directory*.
#### We have defined the config file, now let's see how to access any agruments! Execute `python quick_hier.py` in work directory.

from easy_configer.Configer import Configer

Expand Down Expand Up @@ -313,6 +314,8 @@ However, the syntax of above config file could be improved, isn't it !? For exam
# do whatever you want to do!
#### **3. Access all arguments flexibly**
For `easy_configer>=v2.4.0`, each argument declared under section will be stored in a special dictionary object, called `AttributeDict` (Inhert from native python `dict`). It's a new container allowing dot-operator for accessing any nested object.
The only pitfall about AttributeDict is that **you should never access its `__dict__` property**, since it's disabled..
We simple set a breakpoint to feel how flexible does `easy_configer.utils.Container.AttributeDict` support.

from easy_configer.Configer import Configer
Expand Down Expand Up @@ -369,7 +372,9 @@ Like `omegaconf`, most of user expect to seperate the config based on their type
1. you can call the `cfg_from_ini` twice, for example, `cfg.cfg_from_ini('./base_cfg') ; cfg.cfg_from_ini('./override_cfg')`. But it's not explicitly load the config thus reducing readability.
2. you can use the config merging, for example, `new_cfg = base_cfg | override_cfg`. But it's not elegant solution while you have to merge several config..

#### Now, we provide the thrid way : **sub-config**. you can import the sub-config in any depth of hierachical config by simply placing the `>` symbol at the beginning of line.
#### Now, we provide the thrid way : **sub-config**. you can import the sub-config in any depth of hierachical config by simply placing the `>` symbol at the beginning of line. Also note that sub-config doesn't allow you override the declared argument by default, since dynamically override the arguments made your config hard to trace..
> If you want to override the config, turn the flag allow_override as True. i.e. `cfg.cfg_from_ini(..., allow_override=True)`, `cfg.cfg_from_str(..., allow_override=True)`. The sub-config will follow the flag setting to override the config or raise the RuntimeError.
# ./base_cfg.ini
glb_seed = 42@int
[dataset]
Expand Down Expand Up @@ -459,6 +464,8 @@ In the following example, you can see that the merging config system already pro

### **Miscellnous features**
#### **7. IO Converter**
To convert the `easy_configer` type config into the other config instance, we provide a IO converter to serve for this requirement. IO converter support several well-know config type.. Just simple call the method with the proper arguments as the following example.

from dataclasses import dataclass
from typing import Optional

Expand Down
Binary file modified docs/en/build/doctrees/About.doctree
Binary file not shown.
Binary file modified docs/en/build/doctrees/Metainfo.doctree
Binary file not shown.
Binary file modified docs/en/build/doctrees/Usage.doctree
Binary file not shown.
Binary file modified docs/en/build/doctrees/environment.pickle
Binary file not shown.
Binary file modified docs/en/build/doctrees/index.doctree
Binary file not shown.
11 changes: 5 additions & 6 deletions docs/en/build/html/About.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">About this project</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#preface">Preface ✨</a></li>
<li class="toctree-l2"><a class="reference internal" href="#introduction">Introduction 📝</a></li>
Expand Down Expand Up @@ -86,9 +85,9 @@
<h1>About this project<a class="headerlink" href="#about-this-project" title="Permalink to this heading"></a></h1>
<section id="preface">
<h2>Preface ✨<a class="headerlink" href="#preface" title="Permalink to this heading"></a></h2>
<p>easy_configer version : 2.3.2</p>
<p>easy_configer version : 2.5.2</p>
<blockquote>
<div><p>Note : version 2.3.1 just a document fixup for pypi</p>
<div><p>Note : version 2.5.2 just add new document</p>
</div></blockquote>
<p>Configeruating the program in an easy-way</p>
<p>I’m willing to provide a light-weight solution for configurating your python program.
Expand Down Expand Up @@ -129,9 +128,9 @@ <h2>Introduction 📝<a class="headerlink" href="#introduction" title="Permalink
<ul class="simple">
<li><p>dot-access of any arguments (even in nested dictionary)</p></li>
<li><p>inline comment ‘#’, now you can write comment in everyline ~</p></li>
<li><p>support arguments interpolation!!</p></li>
<li><p>support config argument interpolation, inline-intepolation is also online now ~</p></li>
<li><p>support config conversion, which turn easy_config into the other kind of config package (omegaconf, argparse, …, etc.)</p></li>
<li><p>support hierachical configurating system with dynamic override ~</p></li>
<li><p>support hierachical configuration system with dynamic loading ~</p></li>
</ul>
</section>
</section>
Expand Down
3 changes: 1 addition & 2 deletions docs/en/build/html/Installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="About.html">About this project</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Installation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#how-to-install-br">How to install ? ⚙️<span class="raw-html-m2r"><br></span></a></li>
Expand Down
17 changes: 8 additions & 9 deletions docs/en/build/html/Metainfo.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="About.html">About this project</a></li>
<li class="toctree-l1"><a class="reference internal" href="Installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="Quick.html">Quick start</a></li>
Expand Down Expand Up @@ -88,25 +87,25 @@ <h1>Meta information<a class="headerlink" href="#meta-information" title="Permal
<section id="newly-update-features">
<h2>Newly update features 🚀<a class="headerlink" href="#newly-update-features" title="Permalink to this heading"></a></h2>
<ol class="arabic simple">
<li><p>Enable all test case (automatically ci by git-action)</p></li>
<li><p>Support dot-access of any arguments</p></li>
<li><p>Consistent import syntax..</p></li>
<li><p>New document is released ~</p></li>
<li><p>Easy-configer pass all test-case, and v2.5.2 is the stable version.</p></li>
<li><p>Integrate argument intepolation with using ${cfg} notation</p></li>
<li><p>Integrate enviroment variable intepolation with using ${cfg} notation</p></li>
</ol>
</section>
<hr class="docutils" />
<section id="todo-list">
<h2>TODO List 🔨<a class="headerlink" href="#todo-list" title="Permalink to this heading"></a></h2>
<ol class="arabic simple">
<li><p>Better <strong>exception mechniasm</strong> in easy-config ~</p></li>
<li><p>Better <strong>config syntax</strong> in easy-config ~</p></li>
</ol>
<blockquote>
<div><p>next version released features v 2.3.3</p>
<div><p>next version released features v 2.6</p>
</div></blockquote>
</section>
<section id="bug-fixed">
<h2>Bug Fixed 🐛<a class="headerlink" href="#bug-fixed" title="Permalink to this heading"></a></h2>
<p>Fix-up import syntax.. plz open an issue if you find a bug ~</p>
<p>Due to safty policy, we rollback the feature “single line python code interpreter”..
Hot-fix config overrided bug, add flag for support allow_override..</p>
</section>
<hr class="docutils" />
<section id="simple-unittest">
Expand Down
3 changes: 1 addition & 2 deletions docs/en/build/html/Quick.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="About.html">About this project</a></li>
<li class="toctree-l1"><a class="reference internal" href="Installation.html">Installation</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Quick start</a><ul>
Expand Down
36 changes: 24 additions & 12 deletions docs/en/build/html/Usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul class="current">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="About.html">About this project</a></li>
<li class="toctree-l1"><a class="reference internal" href="Installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="Quick.html">Quick start</a></li>
Expand Down Expand Up @@ -146,14 +145,14 @@ <h2>1. How to declare hierachical config 🖋️<a class="headerlink" href="#how
</div>
<p>However, the syntax of above config file could be improved, isn’t it !? For example, the batch_size is defined twice under <code class="docutils literal notranslate"><span class="pre">dataset.loader</span></code> and <code class="docutils literal notranslate"><span class="pre">train_cfg</span></code>, so as layer seed. Moreover, path is defined as python string, it need to be further converted by Path object in python standard package. Could we regist our customized data type for easy-config ?
Glade to say : Yes! it’s possible to elegantly deal with above mentioned issue. We can solve the first issue by using argument interpolation, and solve the second issue by using the customized register!!</p>
<p><em>config interpolation with $ symbol</em> and customized register method <code class="docutils literal notranslate"><span class="pre">regist_cnvtor</span></code></p>
<p>Thanks to <em>python format-string via ${…}</em> and <em>customized register method `regist_cnvtor`</em>. <em>See below example</em></p>
<blockquote>
<div><p>Currently we support interpolation mechnaism to interpolate <strong>ANY</strong> arguemnts belong the different level of nested dictionary. Moreover, we also support <strong>$Env</strong> for accessing enviroment variables exported in bash!!</p>
<div><p>Currently we support interpolation mechnaism to interpolate <strong>ANY</strong> arguemnts belonging the different level of nested dictionary by using <strong>${cfg}</strong>. Moreover, we also support <strong>${env}</strong> for accessing enviroment variables exported in bash!!</p>
</div></blockquote>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="c1"># For convience, we define string-config!</span>
<span class="k">def</span> <span class="nf">get_str_cfg</span><span class="p">():</span>
<span class="w"> </span><span class="sd">&#39;&#39;&#39; # `export glb_seed=42` in bash!!</span>
<span class="sd"> glb_seed = $Env.glb_seed</span>
<span class="sd"> glb_seed = ${env.glb_seed}@int # or ${env.glb_seed} for short</span>
<span class="sd"> exp_id = &#39;0001&#39;</span>

<span class="sd"> [dataset]</span>
Expand All @@ -164,15 +163,20 @@ <h2>1. How to declare hierachical config 🖋️<a class="headerlink" href="#how

<span class="sd"> [dataset.loader]</span>
<span class="sd"> batch_size = 32</span>
<span class="sd"> secrete_seed = 55688</span>

<span class="sd"> [model]</span>
<span class="sd"> [model.backbone]</span>
<span class="sd"> mod_typ = &#39;resnet&#39;</span>
<span class="sd"> [model.backbone.optimizer]</span>
<span class="sd"> lay_seed = $glb_seed</span>
<span class="sd"> [model.backbone.optimizer]</span>
<span class="sd"> # aweason! but we can do more crazy stuff ~</span>
<span class="sd"> lay_seed = ${cfg.glb_seed}</span>
<span class="sd"> # &#39;cfg&#39; is used to access the config, feel free to access any arguments defined previsouly!!</span>
<span class="sd"> string_seed = &quot;The secrete string in data loader is ${cfg.dataset.loader.secrete_seed}!!&quot;</span>

<span class="sd"> [train_cfg]</span>
<span class="sd"> batch_size = $dataset.loader.batch_size</span>
<span class="sd"> batch_size = ${cfg.dataset.loader.batch_size}</span>
<span class="sd"> exp_id = &quot;${cfg.exp_id}&quot; # or ${cfg.exp_id}@str, quote can not be omitted!</span>
<span class="sd"> [train_cfg.opt]</span>
<span class="sd"> opt_typ = &#39;Adam&#39;</span>
<span class="sd"> lr = 1e-4</span>
Expand All @@ -195,7 +199,9 @@ <h2>1. How to declare hierachical config 🖋️<a class="headerlink" href="#how
<hr class="docutils" />
<section id="access-all-arguments-flexibly">
<h2>2. Access all arguments flexibly 🔓<a class="headerlink" href="#access-all-arguments-flexibly" title="Permalink to this heading"></a></h2>
<p>We simple set a breakpoint to feel how flexible does <code class="docutils literal notranslate"><span class="pre">easy_configer.utils.Container.AttributeDict</span></code> support.</p>
<p>For <code class="docutils literal notranslate"><span class="pre">easy_configer&gt;=v2.4.0</span></code>, each argument declared under section will be stored in a special dictionary object, called <cite>AttributeDict</cite> (Inhert from native python <cite>dict</cite>). It’s a new container allowing dot-operator for accessing any nested object.
The only pitfall about AttributeDict is that <strong>you should never access its `__dict__` property</strong>, since it’s disabled..
We simple set a breakpoint to feel how flexible does <code class="docutils literal notranslate"><span class="pre">easy_configer.utils.Container.AttributeDict</span></code> support.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">easy_configer.Configer</span> <span class="kn">import</span> <span class="n">Configer</span>

<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span>
Expand Down Expand Up @@ -259,7 +265,12 @@ <h2>4. Import Sub-Config 🎎<a class="headerlink" href="#import-sub-config" tit
<li><p>you can call the <code class="docutils literal notranslate"><span class="pre">cfg_from_ini</span></code> twice, for example, <code class="docutils literal notranslate"><span class="pre">cfg.cfg_from_ini('./base_cfg')</span> <span class="pre">;</span> <span class="pre">cfg.cfg_from_ini('./override_cfg')</span></code>. But it’s not explicitly load the config thus reducing readability.</p></li>
<li><p>you can use the config merging, for example, <code class="docutils literal notranslate"><span class="pre">new_cfg</span> <span class="pre">=</span> <span class="pre">base_cfg</span> <span class="pre">|</span> <span class="pre">override_cfg</span></code>. But it’s not elegant solution while you have to merge several config..</p></li>
</ol>
<p>Now, we provide the thrid way : <strong>sub-config</strong>. you can import the sub-config in any depth of hierachical config by simply placing the <code class="docutils literal notranslate"><span class="pre">&gt;</span></code> symbol at the beginning of line.</p>
<p>Now, we provide the thrid way : <strong>sub-config</strong>. you can import the sub-config in any depth of hierachical config by simply placing the <code class="docutils literal notranslate"><span class="pre">&gt;</span></code> symbol at the beginning of line.
Also note that sub-config doesn’t allow you override the declared argument by default, since dynamically override the arguments made your config hard to trace..</p>
<blockquote>
<div><p>If you want to override the config, turn the flag allow_override as True. i.e. <code class="docutils literal notranslate"><span class="pre">cfg.cfg_from_ini(...,</span> <span class="pre">allow_override=True)</span></code>, <code class="docutils literal notranslate"><span class="pre">cfg.cfg_from_str(...,</span> <span class="pre">allow_override=True)</span></code>.
The sub-config will follow the flag setting to override the config or raise the RuntimeError.</p>
</div></blockquote>
<div class="highlight-ini notranslate"><div class="highlight"><pre><span></span><span class="c1"># ./base_cfg.ini</span>
<span class="na">glb_seed</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">42@int</span>
<span class="k">[dataset]</span>
Expand All @@ -279,7 +290,7 @@ <h2>4. Import Sub-Config 🎎<a class="headerlink" href="#import-sub-config" tit
<span class="w"> </span><span class="na">mod_typ</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">&#39;resnet&#39;</span>
<span class="w"> </span><span class="k">[model.backbone.optimizer]</span>
<span class="w"> </span><span class="c1"># and yes, interpolation is still valid &quot;after&quot; the reference argument is declared!</span>
<span class="w"> </span><span class="na">lay_seed</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">$glb_seed</span>
<span class="w"> </span><span class="na">lay_seed</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">${cfg.glb_seed}</span>
</pre></div>
</div>
</section>
Expand All @@ -306,7 +317,7 @@ <h2>5. Config Operation ⛩️<a class="headerlink" href="#config-operation" tit
<span class="s1"> [ghyu.opop]</span>
<span class="s1"> add = 32@int</span>
<span class="s1"> [ghyu.opop.tueo]</span>
<span class="s1"> salt = $inpo</span>
<span class="s1"> salt = $</span><span class="si">{cfg.inpo}</span>

<span class="s1"> # Cell cfg written by Josef-Huang..</span>
<span class="s1"> &#39;&#39;&#39;</span>
Expand Down Expand Up @@ -354,6 +365,7 @@ <h2>5. Config Operation ⛩️<a class="headerlink" href="#config-operation" tit
</section>
<section id="io-converter">
<h2>6. IO Converter 🐙<a class="headerlink" href="#io-converter" title="Permalink to this heading"></a></h2>
<p>To convert the <cite>easy_configer</cite> type config into the other config instance, we provide a IO converter to serve for this requirement. IO converter support several well-know config type.. Just simple call the method with the proper arguments as the following example.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">dataclasses</span> <span class="kn">import</span> <span class="n">dataclass</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Optional</span>

Expand Down
Loading

0 comments on commit 2ab2740

Please sign in to comment.