Example #1
0
 def test_get_loadable_class_name_from_entity_type(self):
     from trustedanalytics.meta.names import entity_type_to_class_name
     self.assertEqual("LogisticRegressionModel", entity_type_to_class_name("model:logistic_regression"))
     self.assertEqual("_BaseModel", entity_type_to_class_name("model"))
     with self.assertRaises(ValueError) as cm:
         entity_type_to_class_name("")
     self.assertEqual(str(cm.exception), "Invalid empty entity_type, expected non-empty string")
Example #2
0
 def test_get_loadable_class_name_from_entity_type(self):
     from trustedanalytics.meta.names import entity_type_to_class_name
     self.assertEqual("LogisticRegressionModel", entity_type_to_class_name("model:logistic_regression"))
     self.assertEqual("_BaseModel", entity_type_to_class_name("model"))
     with self.assertRaises(ValueError) as cm:
         entity_type_to_class_name("")
     self.assertEqual(str(cm.exception), "Invalid empty entity_type, expected non-empty string")
Example #3
0
def write_py_rst_collections_file(root_path, collection_name, subfolders, files):
    # go through subfolders and find the index.rst and add to toc jazz
    # go through files and list global methods  (leave making nice "summary table" as another exercise)
    title = upper_first(collection_name)
    title_emphasis = "=" * len(title)
    # Frame <frame-/index.rst>
    toctree = indent("\n".join(["%s <%s/index.rst>" % (entity_type_to_class_name(subfolder.replace('-',':')), subfolder) for subfolder in subfolders]))
    names =[f[:-4] for f in files if f[-4:] == ".rst" and f != "index.rst"]
    globs = "\n\n".join([":doc:`%s<%s>`" % (name, name) for name in names])
    hidden_toctree = indent("\n".join(names))
    content = """
{title}
{title_emphasis}

**Classes**

.. toctree::
{toctree}

.. toctree::
    :hidden:

{hidden_toctree}

-------

**Global Methods**

{globs}
""".format(title=title, title_emphasis=title_emphasis, toctree=toctree, hidden_toctree=hidden_toctree, globs=globs)
    file_path = os.path.join(root_path, "index.rst")
    write_text_to_file(file_path, content)
Example #4
0
def write_py_rst_collections_file(root_path, collection_name, subfolders, files):
    # go through subfolders and find the index.rst and add to toc jazz
    # go through files and list global methods  (leave making nice "summary table" as another exercise)
    title = upper_first(collection_name)
    title_emphasis = "=" * len(title)
    # Frame <frame-/index.rst>
    toctree = indent("\n".join(["%s <%s/index.rst>" % (entity_type_to_class_name(subfolder.replace('-',':')), subfolder) for subfolder in subfolders]))
    names =[f[:-4] for f in files if f[-4:] == ".rst" and f != "index.rst"]
    globs = "\n\n".join([":doc:`%s<%s>`" % (name, name) for name in names])
    hidden_toctree = indent("\n".join(names))
    content = """
{title}
{title_emphasis}

**Classes**

.. toctree::
{toctree}

.. toctree::
    :hidden:

{hidden_toctree}

-------

**Global Methods**

{globs}
""".format(title=title, title_emphasis=title_emphasis, toctree=toctree, hidden_toctree=hidden_toctree, globs=globs)
    file_path = os.path.join(root_path, "index.rst")
    write_text_to_file(file_path, content)
Example #5
0
 def get_class_and_baseclass_names(self):
     """Returns both the name of the Python class for this install path and the name of its base class"""
     suffix = ''.join([n[0].upper() + n[1:] for n in self._intermediate_names])
     class_prefix = entity_type_to_class_name(self.entity_type) + suffix
     baseclass_prefix = entity_type_to_baseclass_name(self.entity_type)
     if baseclass_prefix != "CommandInstallable":
         baseclass_prefix += suffix
     return class_prefix, baseclass_prefix
Example #6
0
 def test_get_loadable_class_name_from_entity_type(self):
     cases = [
         ('frame', "_BaseFrame"),
         ('frame:', "Frame"),
         ('frame:edge', "EdgeFrame"),
         ('frame:vertex', "VertexFrame"),
         ('graph', "_BaseGraph"),
         ('graph:', "Graph"),
         ('model', "_BaseModel"),
         ]
     for entity_type, expected in cases:
         self.assertEqual(expected, entity_type_to_class_name(entity_type))
 def test_get_loadable_class_name_from_entity_type(self):
     cases = [
         ('frame', "_BaseFrame"),
         ('frame:', "Frame"),
         ('frame:edge', "EdgeFrame"),
         ('frame:vertex', "VertexFrame"),
         ('graph', "_BaseGraph"),
         ('graph:', "Graph"),
         ('model', "_BaseModel"),
     ]
     for entity_type, expected in cases:
         self.assertEqual(expected, entity_type_to_class_name(entity_type))
Example #8
0
 def get_generic_doc_str(self):
     """Creates a generic doc string based solely on the install path's full string"""
     class_name = entity_type_to_class_name(self.entity_type)
     if self.is_entity:
         return "Entity %s" % class_name
     return "Provides functionality scope for entity %s" % class_name