Miscellaneous Classes¶
Repr - Convenience class for default printing¶
NameString - Convert string between cases¶
-
class
hypergol.name_string.NameString(name, plural=None)[source]¶ Class to generate strings of various cases
NameString stores the input string in components. The components are detected by splitting up the input name by single capital letters and underscores.
An irregular plural version can be supplied; otherwise an ‘es’ or ‘s’ will be attached to the end to get plural form.
-
__init__(name, plural=None)[source]¶ - Parameters
name (string) – String in any case
plural (string (default=None)) – If the plural form of a word is irregular, it can be provided here the same style as the name
-
property
asFileName¶ Returns the standard python filename
e.g.: HelloWorld -> hello_world.py
-
property
asSnake¶ Returns the string as snakecase
e.g.: HelloWorld -> hello_world
-
property
asClass¶ Returns the string as a class name (PascalCase)
e.g.: HelloWorld -> HelloWorld
-
property
asVariable¶ Returns the string as a variable name (camelCase)
e.g.: HelloWorld -> helloWorld
-
property
asPluralVariable¶ Returns the string as a plural variable name
e.g.: HelloWorld -> helloWorlds
Used for autogenerating dataset variable names
-
property
asPluralSnake¶ Returns the string as a plural snakecase name
e.g.: HelloWorld -> hello_worlds
Used for autogenerating dataset file names
-
HypergolProject - Class to manage information about the project¶
-
class
hypergol.hypergol_project.HypergolProject(projectDirectory=None, dataDirectory='.', chunkCount=16, dryrun=None, force=None, repoManager=None)[source]¶ Owner of all information about the project
CLI functions define what needs to be created, and this class creates them. It also consistently handles the mode flags (normal/dryrun/force)
It also verifies if a requested class exists in the respective directory (data_models, tasks) and identifies its type, e.g.: for
HelloWorldit checks ifdata_models/hello_world.pyortasks/hello_world.pyexists and assumes its role from that. Used increate_data_model()andcreate_pipeline()-
__init__(projectDirectory=None, dataDirectory='.', chunkCount=16, dryrun=None, force=None, repoManager=None)[source]¶ - Parameters
projectDirectory (string) – location of the project: e.g.:
~/repo_name, models will be in~/repo_name/modelsprojectDirectory – location of the data for the project project: e.g.:
~/data, files will be stored in~/data/repo_namedryrun (bool (default=None)) – If set to
Trueit returns the generated code as a stringforce (bool (default=None)) – If set to
Trueit overwrites the target file
-
property
isDryRun¶
-
property
modeMessage¶
-
is_data_model_class(value: hypergol.name_string.NameString)[source]¶ Checks if a name is a data_model class (based on if the snakecase .py file exists)
-
is_task_class(value: hypergol.name_string.NameString)[source]¶ Checks if a name is in tasks class (based on if the snakecase .py file exists)
-
is_model_block_class(value: hypergol.name_string.NameString)[source]¶ Checks if a name is in blocks class (based on if the snakecase .py file exists)
-
render(templateName, templateData, filePath)[source]¶ Creates a file from a template using jinja2
- Parameters
templateName (string) – filename of the template
templateData (dict) – data to fill the template with
filePath (Path) – full path of the destination file (ignored if self.mode != Mode.DRY_RUN)
-
list_datasets(pattern=None, asCode=False)[source]¶ Convenience function to list datasets for a project
Returns a list of data loaded from the
.deffiles in the directory- Parameters
pattern (string (None)) – Regex pattern to filter on dataset names, if unspecified, defaults to
.*asCode (bool (False)) – If True prints a code snippet that allows the dataset to be loaded (with imports and path updates)
-
diff_data_model(commit, *args)[source]¶ Convenience function to compare old data model class definitions to the current one
Prints the diffs from the specified commit to the current commit
- Parameters
commit (string) – The git commit from where the comparison starts
*args (List[string]) – List of class names to compare, if empty it compares all
-
create_old_data_model(commit, *args)[source]¶ Convenience function to generate data model classes at an old commit to be able to load datasets created then
Full commit hash required.
project.create_old_data_model(commit='fbd8110b7194425e2323f68ef54dac15bb01ee7b', 'OneClass', 'TwoClass')Will create
data_models/one_class_fbd8110.pyanddata_models/two_class_fbd8110.pyand replaces all occurences ofOneClassandTwoClasstoOneClassFBD8110andTwoClassFBD8110in each file.- Parameters
commit (string) – git commit to retrieve classes from
args (List[string]) – List of class names to generate, if empty it generates all
-
RepoManager - Helper class for storing Repository information¶
RepoData - Data class for storing Repository informations¶
-
class
hypergol.dataset.RepoData(branchName, commitHash, commitMessage, comitterName, comitterEmail)[source]¶ Stores the information about the repository in the dataset
Logger - Class for logging¶
-
class
hypergol.logger.Logger(path=None, level=20, overWrite=False, enabled=True)[source]¶ Helper class to manage file-based and screen-based logging
-
CRITICAL= 50¶
-
ERROR= 40¶
-
WARNING= 30¶
-
INFO= 20¶
-
DEBUG= 10¶
-
NOTSET= 0¶
-
__init__(path=None, level=20, overWrite=False, enabled=True)[source]¶ - Parameters
path (str (default=None)) – Optional path to save logs into a file
level (int (default=Logger.INFO)) – Log level of this logger
overWrite (bool (default=False)) – Indicate if an existing log file should be overwritten or appended
-