Examples: query, "exact match", wildcard*, wild?ard, wild*rd
Fuzzy search: cake~ (finds cakes, bake)
Term boost: "red velvet"^4, chocolate^2
Field grouping: tags:(+work -"fun-stuff")
Escaping: Escape characters +-&|!(){}[]^"~*?:\ with \, e.g. \+
Range search: properties.timestamp:[1587729413488 TO *] (inclusive), properties.title:{A TO Z}(excluding A and Z)
Combinations: chocolate AND vanilla, chocolate OR vanilla, (chocolate OR vanilla) NOT "vanilla pudding"
Field search: properties.title:"The Title" AND text
Answered
Hi There, I'Ve Encountered A Problematic Behavior In Python. When Defining An Argument A Default Value Of

Hi there, I've encountered a problematic behavior in python. When defining an argument a default value of None connecting to trains server then copy the task and run it again I'm getting back that value as an empty string instead of None again. Is this a known issue or I'm doing something wrong in the arguments definition?

  
  
Posted 4 years ago
Votes Newest

Answers 24


yes, there's a use for empty strings, for example in text generation you may generate the next word given some prefix, the prefix may be an empty string.

  
  
Posted 4 years ago

the version of the agent (the worker that received the job was 0.14.1)
the one that created the template was 0.14.2

  
  
Posted 4 years ago

Hmm, I still wonder what is the "correct" answer for most people, is empty string in argparse redundant anyhow? will someone ever use it?

  
  
Posted 4 years ago

thanks

  
  
Posted 4 years ago

Hmm... That's what happens with the exception of None/'' if type is str... There is no way to differentiate in the UI.
This is why we opted for type=str will "cast" everything to str so you always get str, while not specifying a type will leave the variable as is... If you have an idea on how to support both, feel free to suggest 🙂

  
  
Posted 4 years ago

PompousBeetle71 BTW: if you remove the type=str from the argparse, it will do what you want, None will stay None (instead of ''), all other values will be of type str as this is always the default 🙂

  
  
Posted 4 years ago

PompousBeetle71 is this ArgParser argument or a connected dictionary ?

  
  
Posted 4 years ago

Another question, do you have the argparse with type=str ?

  
  
Posted 4 years ago

PompousBeetle71 quick question, will you ever want to pass an empty string ? reason for asking is that it is either one or the other, there is no way for Trains to actually differentiate (from the web UI, perspective this is just an empty string field...)

  
  
Posted 4 years ago

AgitatedDove14 no, there's no reason in my case to pass an empty string. that's why I removed the type=str part.

  
  
Posted 4 years ago

i.e. run
pip install --upgrade trains

  
  
Posted 4 years ago

AgitatedDove14 ArgParser argument

  
  
Posted 4 years ago

PompousBeetle71 Could you check with 0.14.3 that just released?

  
  
Posted 4 years ago

btw: both should work fine

  
  
Posted 4 years ago

AgitatedDove14 v0.14

  
  
Posted 4 years ago

I think if there's a default value it should override the type, otherwise go with the type

  
  
Posted 4 years ago

And the trains version?

  
  
Posted 4 years ago

Hi PompousBeetle71
I remember it was an issue, but it was solved a while ago. Which Trains version are you using?

  
  
Posted 4 years ago

I thought to change to connected ditionary though.

  
  
Posted 4 years ago

AgitatedDove14 When the default is None I expect the default value to be None even if the type is str. But I'll use your recommendation 🙂

  
  
Posted 4 years ago

I mean , the python package, not the trains-server version

  
  
Posted 4 years ago

PompousBeetle71 If this is argparser and the type is defined, the trains-agent will pass the equivalent in the same type, with str that amounts to '' . make sense ?

  
  
Posted 4 years ago

yes, it was.

  
  
Posted 4 years ago

the trains version is still 0.14 it will take time to switch it

  
  
Posted 4 years ago
1K Views
24 Answers
4 years ago
one year ago
Tags