Skip to content

Commit

Permalink
fix: fix warning when env vars used (#4291)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoanFM committed Feb 12, 2022
1 parent 386d63a commit cfa8395
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
1 change: 1 addition & 0 deletions cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def _get_run_args(print_args: bool = True):
if unknown:
from jina.helper import warn_unknown_args

unknown = list(filter(lambda x: x.startswith('--'), unknown))
warn_unknown_args(unknown)

if args.cli not in silent_print and print_args:
Expand Down
26 changes: 13 additions & 13 deletions jina/helloworld/multimodal/flow-index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,60 +5,60 @@ executors:
uses:
jtype: Segmenter
metas:
workspace: $HW_WORKDIR
workspace: ${{ ENV.HW_WORKDIR }}
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: craftText
uses:
jtype: TextCrafter
metas:
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: encodeText
uses:
jtype: TextEncoder
metas:
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: textIndexer
uses:
jtype: DocVectorIndexer
with:
index_file_name: "text.json"
metas:
workspace: $HW_WORKDIR
workspace: ${{ ENV.HW_WORKDIR }}
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: craftImage
uses:
jtype: ImageCrafter
metas:
workspace: $HW_WORKDIR
workspace: ${{ ENV.HW_WORKDIR }}
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
needs: segment
- name: encodeImage
uses:
jtype: ImageEncoder
metas:
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: imageIndexer
uses:
jtype: DocVectorIndexer
with:
index_file_name: "image.json"
metas:
workspace: $HW_WORKDIR
workspace: ${{ ENV.HW_WORKDIR }}
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: keyValueIndexer
uses:
jtype: KeyValueIndexer
metas:
workspace: $HW_WORKDIR
workspace: ${{ ENV.HW_WORKDIR }}
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
needs: segment
- name: joinAll
needs: [ textIndexer, imageIndexer, keyValueIndexer ]
26 changes: 13 additions & 13 deletions jina/helloworld/multimodal/flow-search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,58 @@ executors:
jtype: TextCrafter
metas:
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: encodeText
uses:
jtype: TextEncoder
metas:
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: textIndexer
uses:
jtype: DocVectorIndexer
with:
index_file_name: "text.json"
metas:
workspace: $HW_WORKDIR
workspace: ${{ ENV.HW_WORKDIR }}
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: craftImage
uses:
jtype: ImageCrafter
metas:
workspace: $HW_WORKDIR
workspace: ${{ ENV.HW_WORKDIR }}
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
needs: gateway
- name: encodeImage
uses:
jtype: ImageEncoder
metas:
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: imageIndexer
uses:
jtype: DocVectorIndexer
with:
index_file_name: "image.json"
metas:
workspace: $HW_WORKDIR
workspace: ${{ ENV.HW_WORKDIR }}
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
- name: weightedRanker
uses:
jtype: WeightedRanker
metas:
workspace: $HW_WORKDIR
workspace: ${{ ENV.HW_WORKDIR }}
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
needs: [ textIndexer, imageIndexer ]
- name: keyvalueIndexer
uses:
jtype: KeyValueIndexer
metas:
workspace: $HW_WORKDIR
workspace: ${{ ENV.HW_WORKDIR }}
py_modules:
- $PY_MODULE
- ${{ ENV.PY_MODULE }}
needs: weightedRanker
2 changes: 1 addition & 1 deletion jina/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,6 @@ def warn_unknown_args(unknown_args: List[str]):
from cli.lookup import _build_lookup_table

all_args = _build_lookup_table()[0]

has_migration_tip = False
real_unknown_args = []
warn_strs = []
Expand Down Expand Up @@ -773,6 +772,7 @@ def kwargs2namespace(
if positional_args:
args += positional_args
p_args, unknown_args = parser.parse_known_args(args)
unknown_args = list(filter(lambda x: x.startswith('--'), unknown_args))
if warn_unknown and unknown_args:
_leftovers = set(unknown_args)
if fallback_parsers:
Expand Down
4 changes: 3 additions & 1 deletion jina/jaml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,9 @@ def _sub(v):
# 2) env variables placeholder are cast to $var then we leverage the os.path.expandvars to replace by
# environment variables.

if env_var_deprecated_regex.findall(v): # catch expressions of form '$var'
if env_var_deprecated_regex.findall(v) and not env_var_regex.findall(
v
): # catch expressions of form '$var'
warnings.warn(
'Specifying environment variables via the syntax `$var` is deprecated.'
'Use `${{ ENV.var }}` instead.',
Expand Down

0 comments on commit cfa8395

Please sign in to comment.