Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parsing of env vars of the form '{ var }' #4229

Merged
merged 11 commits into from
Feb 3, 2022
Merged

Conversation

JohannesMessner
Copy link
Contributor

No description provided.

@github-actions github-actions bot added size/S area/core This issue/PR affects the core codebase area/testing This issue/PR affects testing component/jaml labels Jan 31, 2022
@codecov
Copy link

codecov bot commented Jan 31, 2022

Codecov Report

Merging #4229 (ba8bb18) into master (1d6c077) will decrease coverage by 0.54%.
The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4229      +/-   ##
==========================================
- Coverage   87.40%   86.86%   -0.55%     
==========================================
  Files         114      114              
  Lines        8284     8306      +22     
==========================================
- Hits         7241     7215      -26     
- Misses       1043     1091      +48     
Flag Coverage Δ
daemon 42.29% <56.25%> (-0.17%) ⬇️
jina 86.61% <93.75%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
jina/jaml/__init__.py 95.43% <93.54%> (-0.04%) ⬇️
jina/serve/executors/__init__.py 83.45% <100.00%> (ø)
jina/serve/networking.py 71.27% <0.00%> (-12.20%) ⬇️
jina/orchestrate/peas/jinad.py 93.02% <0.00%> (-1.56%) ⬇️
jina/orchestrate/pods/__init__.py 80.80% <0.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d6c077...ba8bb18. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Jan 31, 2022

Latency summary

Current PR yields:

  • 🐢🐢 index QPS at 870, delta to last 2 avg.: -31%
  • 🐎🐎🐎🐎 query QPS at 47, delta to last 2 avg.: +112%
  • 🐢🐢 avg flow time within 1.3116 seconds, delta to last 2 avg.: -14%
  • 😶 import jina within 0.3985 seconds, delta to last 2 avg.: -2%

Breakdown

Version Index QPS Query QPS Avg Flow Time (s) Import Time (s)
current 870 47 1.3116 0.3985
2.6.4 1315 22 1.517 0.3997
2.6.3 1215 22 1.559 0.4142

Backed by latency-tracking. Further commits will update this comment.

cristianmtr
cristianmtr previously approved these changes Jan 31, 2022
@samsja samsja marked this pull request as ready for review January 31, 2022 16:53
@samsja samsja requested review from jacobowitz and JoanFM and removed request for JoanFM January 31, 2022 16:53
@JohannesMessner JohannesMessner marked this pull request as draft February 1, 2022 07:18
fix: WIP cvoer all jaml parsing case correclty
@JoanFM JoanFM changed the title Fix parsing of env vars of the form '{ var }' 4059 fix: parsing of env vars of the form '{ var }' Feb 2, 2022

Note the mandatory spaces before and after the variable denotation.

Context variables can be accessed using the following syntax:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a context var? Isn't this the same

${{ env.var }}
# and
${{ var }}
```?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the latter refers exclusively to context variables, which can be passed to Flow.load_config(), Executor.load_config(), Jaml.parse() as a dict. Slightly more info is below. We didn't know about these either until we found them during testing.

@@ -494,8 +600,8 @@ def load_config(
:class:`BaseExecutor`, :class:`BaseDriver` and all their subclasses.

Support substitutions in YAML:
- Environment variables: `${{ENV.VAR}}` (recommended), ``${{VAR}}``.
- Context dict (``context``): ``${{VAR}}``(recommended).
- Environment variables: ``${{ ENV.VAR }}`` (recommended), ``$VAR`` (deprecated).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's deprecated, why are we keeping it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General question. can be raised in slack or in an alignment. How long are we going to keep it around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are trying to align with GitHub actions syntax, in which both work, but the first version is encouraged. Han told us to deprecate the second version, my guess is it will stick around for as long as it does within github actions.


To substitute the value based on a dict,
These context variables are passed as a dict:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've always passed env vars directly, without the need to ENV. prefix. Will it not work from now on? In what situation would you want context variables and how would you pass them to a Flow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing env vars like this: ${{ var }} should never have worked in the first place, we believe, and does not work anymore. So now you either do ${{ env.var }} or $var; the latter is discouraged but should work perfectly fine. You should be able to pass a dict containing context variables to Flow.load_config(context={'context_var' : 1}) . Not sure what the use cases for context vars are, though.

@samsja samsja marked this pull request as ready for review February 3, 2022 07:25
@samsja
Copy link
Contributor

samsja commented Feb 3, 2022

@JoanFM JoanFM linked an issue Feb 3, 2022 that may be closed by this pull request
@@ -49,17 +82,45 @@ class DummyClass:
An expression can be any combination of literal values, references to a context, or functions.
You can combine literals, context references, and functions using operators.

You need to use specific syntax to tell Jina to evaluate an expression rather than treat it as a string.
You need to use specific syntax to tell Jina to evaluate an expression rather than treat it as a string,
which is based on GitHub actions syntax, and looks like this:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a link to Github syntax explained?

@JoanFM JoanFM merged commit 34db85a into master Feb 3, 2022
@JoanFM JoanFM deleted the fix-env-vars-4059 branch February 3, 2022 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core This issue/PR affects the core codebase area/testing This issue/PR affects testing component/jaml size/M size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

env vars with { don't get resolved
4 participants