Skip to content

Commit

Permalink
Handle ValidationError within active requests
Browse files Browse the repository at this point in the history
Parse `server_url` to ensure it ends with `/`
Add starup validation for `server_url`
Update .gitignore
  • Loading branch information
dormant-user committed Aug 3, 2024
1 parent b061876 commit 8dbca53
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
.vscode
.DS_Store
__pycache__
_build
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ fail_fast: true
exclude: ^(notebooks/|scripts/|.github/|docs/)
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -27,7 +27,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/PyCQA/flake8
rev: '6.1.0'
rev: '7.1.0'
hooks:
- id: flake8
additional_dependencies:
Expand All @@ -41,7 +41,7 @@ repos:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 5.13.0
hooks:
- id: isort
name: isort (python)
Expand Down
2 changes: 2 additions & 0 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ <h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#jarvis_ui.modules.models.EnvConfig.parse_microphone_index">parse_microphone_index() (jarvis_ui.modules.models.EnvConfig class method)</a>
</li>
<li><a href="index.html#jarvis_ui.modules.models.EnvConfig.parse_server_url">parse_server_url() (jarvis_ui.modules.models.EnvConfig class method)</a>
</li>
<li><a href="index.html#jarvis_ui.modules.models.FileIO.path">path (jarvis_ui.modules.models.FileIO attribute)</a>
</li>
Expand Down
12 changes: 9 additions & 3 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -610,8 +610,14 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"

<dl class="py method">
<dt class="sig sig-object py" id="jarvis_ui.modules.models.EnvConfig.parse_microphone_index">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">parse_microphone_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">v</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#jarvis_ui.modules.models.EnvConfig.parse_microphone_index" title="Permalink to this definition"></a></dt>
<dd><p>Validates microphone index.</p>
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">parse_microphone_index</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">idx</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">int</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">int</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#jarvis_ui.modules.models.EnvConfig.parse_microphone_index" title="Permalink to this definition"></a></dt>
<dd><p>Validate microphone index.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="jarvis_ui.modules.models.EnvConfig.parse_server_url">
<em class="property"><span class="pre">classmethod</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">parse_server_url</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">url</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">Url</span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Optional</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#jarvis_ui.modules.models.EnvConfig.parse_server_url" title="Permalink to this definition"></a></dt>
<dd><p>Validate server_url and return as string.</p>
</dd></dl>

<dl class="py attribute">
Expand Down Expand Up @@ -731,7 +737,7 @@ <h1>Models<a class="headerlink" href="#models" title="Permalink to this heading"

<dl class="py attribute">
<dt class="sig sig-object py" id="jarvis_ui.modules.models.FileIO.model_fields">
<span class="sig-name descname"><span class="pre">model_fields</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">ClassVar</span><span class="p"><span class="pre">[</span></span><span class="pre">dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">FieldInfo</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{'acknowledgement':</span> <span class="pre">FieldInfo(annotation=Path,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/acknowledgement.wav',</span> <span class="pre">metadata=[PathType(path_type='file')]),</span> <span class="pre">'base_log_file':</span> <span class="pre">FieldInfo(annotation=Union[Annotated[pathlib.Path,</span> <span class="pre">PathType(path_type='file')],</span> <span class="pre">str],</span> <span class="pre">required=False,</span> <span class="pre">default='logs/jarvis_02-08-2024.log'),</span> <span class="pre">'connection_restart':</span> <span class="pre">FieldInfo(annotation=Path,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/connection_restart_mac.wav',</span> <span class="pre">metadata=[PathType(path_type='file')]),</span> <span class="pre">'extn_':</span> <span class="pre">FieldInfo(annotation=Dict[str,</span> <span class="pre">str],</span> <span class="pre">required=False,</span> <span class="pre">default={'Darwin':</span> <span class="pre">'mac',</span> <span class="pre">'Windows':</span> <span class="pre">'win',</span> <span class="pre">'Linux':</span> <span class="pre">'ss'}),</span> <span class="pre">'failed':</span> <span class="pre">FieldInfo(annotation=Path,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/failed_mac.wav',</span> <span class="pre">metadata=[PathType(path_type='file')]),</span> <span class="pre">'path':</span> <span class="pre">FieldInfo(annotation=str,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators'),</span> <span class="pre">'restart':</span> <span class="pre">FieldInfo(annotation=Path,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/restart_mac.wav',</span> <span class="pre">metadata=[PathType(path_type='file')]),</span> <span class="pre">'shutdown':</span> <span class="pre">FieldInfo(annotation=Path,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/shutdown_mac.wav',</span> <span class="pre">metadata=[PathType(path_type='file')]),</span> <span class="pre">'speech_wav_file':</span> <span class="pre">FieldInfo(annotation=Union[Annotated[pathlib.Path,</span> <span class="pre">PathType(path_type='file')],</span> <span class="pre">str],</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/speech-synthesis.wav')}</span></em><a class="headerlink" href="#jarvis_ui.modules.models.FileIO.model_fields" title="Permalink to this definition"></a></dt>
<span class="sig-name descname"><span class="pre">model_fields</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">ClassVar</span><span class="p"><span class="pre">[</span></span><span class="pre">dict</span><span class="p"><span class="pre">[</span></span><span class="pre">str</span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">FieldInfo</span><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">]</span></span></em><em class="property"><span class="w"> </span><span class="p"><span class="pre">=</span></span><span class="w"> </span><span class="pre">{'acknowledgement':</span> <span class="pre">FieldInfo(annotation=Path,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/acknowledgement.wav',</span> <span class="pre">metadata=[PathType(path_type='file')]),</span> <span class="pre">'base_log_file':</span> <span class="pre">FieldInfo(annotation=Union[Annotated[pathlib.Path,</span> <span class="pre">PathType(path_type='file')],</span> <span class="pre">str],</span> <span class="pre">required=False,</span> <span class="pre">default='logs/jarvis_03-08-2024.log'),</span> <span class="pre">'connection_restart':</span> <span class="pre">FieldInfo(annotation=Path,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/connection_restart_mac.wav',</span> <span class="pre">metadata=[PathType(path_type='file')]),</span> <span class="pre">'extn_':</span> <span class="pre">FieldInfo(annotation=Dict[str,</span> <span class="pre">str],</span> <span class="pre">required=False,</span> <span class="pre">default={'Darwin':</span> <span class="pre">'mac',</span> <span class="pre">'Windows':</span> <span class="pre">'win',</span> <span class="pre">'Linux':</span> <span class="pre">'ss'}),</span> <span class="pre">'failed':</span> <span class="pre">FieldInfo(annotation=Path,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/failed_mac.wav',</span> <span class="pre">metadata=[PathType(path_type='file')]),</span> <span class="pre">'path':</span> <span class="pre">FieldInfo(annotation=str,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators'),</span> <span class="pre">'restart':</span> <span class="pre">FieldInfo(annotation=Path,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/restart_mac.wav',</span> <span class="pre">metadata=[PathType(path_type='file')]),</span> <span class="pre">'shutdown':</span> <span class="pre">FieldInfo(annotation=Path,</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/shutdown_mac.wav',</span> <span class="pre">metadata=[PathType(path_type='file')]),</span> <span class="pre">'speech_wav_file':</span> <span class="pre">FieldInfo(annotation=Union[Annotated[pathlib.Path,</span> <span class="pre">PathType(path_type='file')],</span> <span class="pre">str],</span> <span class="pre">required=False,</span> <span class="pre">default='/Users/vicky/Desktop/git/Jarvis_UI/jarvis_ui/indicators/speech-synthesis.wav')}</span></em><a class="headerlink" href="#jarvis_ui.modules.models.FileIO.model_fields" title="Permalink to this definition"></a></dt>
<dd><p>Metadata about the fields defined on the model,
mapping of field names to [<cite>FieldInfo</cite>][pydantic.fields.FieldInfo].</p>
<p>This replaces <cite>Model.__fields__</cite> from Pydantic V1.</p>
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
Loading

0 comments on commit 8dbca53

Please sign in to comment.