code: public static TaskTemplate getTaskTemplate(AssetVersionSpec assetVersionSpec) throws Exception {
          TaskTemplate taskTemplate = templateVersions.get(assetVersionSpec.toString());
          if (taskTemplate == null) {
              if (assetVersionSpec.getPackageName() != null) {
                  List<Package> pkgVOs = PackageCache.getAllPackages(assetVersionSpec.getPackageName());
                  for (Package pkgVO : pkgVOs) {
                      for (TaskTemplate template : pkgVO.getTaskTemplates()) {
                          if (assetVersionSpec.getName().equals(template.getName())) {
                              if (template.meetsVersionSpec(assetVersionSpec.getVersion()) && (taskTemplate == null || template.getVersion() > taskTemplate.getVersion()))
                                  taskTemplate = template;
                          }
                      }
                  }
              }
              // If didn't find, check ASSET_REF DB table to retrieve from git history
              if (taskTemplate == null && !assetVersionSpec.getVersion().equals("0")) {
                  AssetRef ref = AssetRefCache.getAssetRef(assetVersionSpec);
                  if (ref != null) {
                      taskTemplate = AssetRefConverter.getTaskTemplate(ref);
                      if (taskTemplate != null)
                          taskVoCache.add(taskTemplate);
                  }
              }
              if (taskTemplate != null)
                  templateVersions.put(assetVersionSpec.toString(), taskTemplate);
          }
          return taskTemplate;
      }
docs: Get the latest task template that matched the assetVersionSpec.
  Uses the task logicalId to match to the taskVoCache, so if the logical ID
  in the matching asset is not unique, then the latest template with this logicalId
  will be returned regardless of assetVersionSpec.
  So CHANGE THE LOGICAL_ID if you want in-flight tasks to use a different template.
  @throws Exception