CORD-2741 pass service versions in LoadModels call

Change-Id: Ib993f875146490e11b4196e91bc5fae8c70529cc
diff --git a/lib/xos-util/xosutil/autodiscover_version.py b/lib/xos-util/xosutil/autodiscover_version.py
index 023aa79..d41f4b3 100644
--- a/lib/xos-util/xosutil/autodiscover_version.py
+++ b/lib/xos-util/xosutil/autodiscover_version.py
@@ -49,3 +49,10 @@
     frame = inspect.stack()[1]
     module = inspect.getmodule(frame[0])
     return autodiscover_version(module.__file__, *args, **kwargs)
+
+def autodiscover_version_of_main(*args, **kwargs):
+    import __main__
+    if hasattr(__main__, "__file__"):
+        return autodiscover_version(__main__.__file__, *args, **kwargs)
+    else:
+        return None
diff --git a/xos/synchronizers/new_base/loadmodels.py b/xos/synchronizers/new_base/loadmodels.py
index b5c0a7d..b9cb1f9 100644
--- a/xos/synchronizers/new_base/loadmodels.py
+++ b/xos/synchronizers/new_base/loadmodels.py
@@ -19,8 +19,8 @@
     def __init__(self, api):
         self.api = api
 
-    def upload_models(self, name, dir):
-        request = self.api.dynamicload_pb2.LoadModelsRequest(name=name, version="unknown")
+    def upload_models(self, name, dir, version="unknown"):
+        request = self.api.dynamicload_pb2.LoadModelsRequest(name=name, version=version)
 
         for fn in os.listdir(dir):
             if fn.endswith(".xproto"):
diff --git a/xos/synchronizers/new_base/modelaccessor.py b/xos/synchronizers/new_base/modelaccessor.py
index f92123b..608b4e0 100644
--- a/xos/synchronizers/new_base/modelaccessor.py
+++ b/xos/synchronizers/new_base/modelaccessor.py
@@ -35,6 +35,7 @@
 
 from xosconfig import Config
 from multistructlog import create_logger
+from xosutil.autodiscover_version import autodiscover_version_of_main
 
 log = create_logger(Config().get('logging'))
 
@@ -163,8 +164,10 @@
     # is waiting on our models.
 
     if Config.get("models_dir"):
+        version = autodiscover_version_of_main() or "unknown"
+        log.info("Service version is %s" % version)
         try:
-            ModelLoadClient(client).upload_models(Config.get("name"), Config.get("models_dir"))
+            ModelLoadClient(client).upload_models(Config.get("name"), Config.get("models_dir"), version=version)
         except Exception, e:  # TODO: narrow exception scope
             if (hasattr(e, "code") and callable(e.code) and hasattr(e.code(), "name") and (e.code().name) == "UNAVAILABLE"):
                 # We need to make sure we force a reconnection, as it's possible that we will end up downloading a