private static void validateModelPath(File modelFile) {
        Pattern nameRegexp = Pattern.compile("[A-Za-z0-9_.]*");

        Path path = Path.fromString(modelFile.toString());
        if (modelFile.isFile())
            path = stripFileEnding(path);

        boolean afterModels = false;
        for (String element : path.elements()) {
            if (afterModels) {
                if ( ! nameRegexp.matcher(element).matches()) {
                    throw new IllegalArgumentException("When Vespa imports a model from the 'models' directory, it " +
                                                       "uses the directory structure under 'models' to determine the " +
                                                       "name of the model. The directory or file name '" + element + "' " +
                                                       "is not valid. Please rename this to only contain letters, " +
                                                       "numbers or underscores.");
                }
            } else if (element.equals("models")) {
                afterModels = true;
            }
        }
    }
Returns an immutable collection of all the imported models
model-integration/src/main/java/ai/vespa/rankingexpression/importer/configmodelview/ImportedMlModels.java