Skip to content

Commit

Permalink
do not ask to select variations in "ck install package" when there ar…
Browse files Browse the repository at this point in the history
…e 2 or more variations!
  • Loading branch information
gfursin committed Apr 23, 2021
1 parent c44a3db commit 63efdfc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* V1.55.10
* do not ask to select variations in "ck install package"
when there are 2 or more variations!

* V1.55.9
* added --force_version to "ck detect soft" to force version.
Useful to automate autodetection of imagenet, for example.
Expand Down
2 changes: 1 addition & 1 deletion ck/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


# We use 3 digits for the main (released) version and 4th digit for development revision
__version__ = "1.55.9"
__version__ = "1.55.10"
# Do not use characters (to detect outdated version)!

# Import packages that are global for the whole kernel
Expand Down
35 changes: 23 additions & 12 deletions ck/repo/module/package/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,27 +494,38 @@ def install(i):

j=0
key_variation={}
count_ons=0
for variation in sorted_supported_variations:
ck.out(str(j)+') '+variation)
x=str(j)+') '+variation

if supported_variations.get(variation,{}).get('on_by_default','')=='yes':
x+=' (on by default)'
count_ons += 1

ck.out(x)

key_variation[j]=variation
j+=1

ck.out('')

if quiet!='yes':
x=input('Please select a variation or press Enter for the default one (0): ')
# If more than 1 default variation found, skip asking which one to select
# (it means that it's unlikely a version selection but an env customization)
if count_ons<2:
if quiet!='yes':
x=input('Please select a variation or press Enter for the default one (0): ')

x=x.strip()
if x=='': x='0'
x=x.strip()
if x=='': x='0'

ix=int(x)
if ix<0 or ix>=j:
return {'return':1, 'error':'variation number is not recognized'}
else:
ck.out('Selected 0 (default)')
ix=0
ix=int(x)
if ix<0 or ix>=j:
return {'return':1, 'error':'variation number is not recognized'}
else:
ck.out('Selected 0 (default)')
ix=0

required_variations=[key_variation[ix]]
required_variations=[key_variation[ix]]

required_vari_pairs = [ (variation_name, False) for variation_name in required_variations ]
default_vari_pairs = [ (variation_name, True) for variation_name in supported_variations if supported_variations[variation_name].get('on_by_default', '')=='yes' ]
Expand Down

0 comments on commit 63efdfc

Please sign in to comment.