CoolFace
Datasetpublic

Fraser/dream-coder

Program Synthesis Data Generated program synthesis datasets used to train dreamcoder. Currently just supports text & list data.

sourceHugging Facemitupdated 4y agoView on Hugging Face
6likes689downloads
__init__.py108 linesDownload Raw Back to dreamcoder
1"""2EC codebase Python library (AKA the "frontend")3 4Module mapping details:5 6TODO: remove module mapping code when backwards-compatibility is no longer required.7 8The below module mapping is required for backwards-compatibility with old pickle files9generated from before the EC codebase refactor. New files added to the codebase do not10need to be added to the mapping, but if the existing modules are moved, then this the11mapping needs to be updated to reflect the move or rename.12 13The mapping uses the following pattern:14 15    sys.modules[<old module path>] = <new module reference>16 17This is because the previous structure of the codebase was completely flat, and when refactoring18to a hierarchical files, loading previous pickle files no longer works properly. It is important19to retain the ability to read old pickle files generated from official experiments. As a workaround,20the old module paths are included below. A preferable alternative would be to export program state21into JSON files instead of pickle files to avoid issues where the underlying classes change, so that22could be a future improvement to this project. Until then, we use the module mapping workaround.23 24For more info, see this StackOverflow answer: https://stackoverflow.com/a/2121918/257324225"""26import sys27 28from dreamcoder import differentiation29from dreamcoder import dreamcoder30from dreamcoder import enumeration31from dreamcoder import fragmentGrammar32from dreamcoder import fragmentUtilities33from dreamcoder import frontier34from dreamcoder import grammar35from dreamcoder import likelihoodModel36from dreamcoder import program37from dreamcoder import primitiveGraph38try:39    from dreamcoder import recognition40except:41    print("Failure loading recognition - only acceptable if using pypy ",file=sys.stderr)42from dreamcoder import task43from dreamcoder import taskBatcher44from dreamcoder import type45from dreamcoder import utilities46from dreamcoder import vs47from dreamcoder.domains.misc import algolispPrimitives, deepcoderPrimitives48from dreamcoder.domains.misc import RobustFillPrimitives49from dreamcoder.domains.misc import napsPrimitives50from dreamcoder.domains.tower import makeTowerTasks51from dreamcoder.domains.tower import towerPrimitives52from dreamcoder.domains.tower import tower_common53from dreamcoder.domains.tower import main as tower_main54from dreamcoder.domains.regex import groundtruthRegexes55from dreamcoder.domains.regex import regexPrimitives56from dreamcoder.domains.regex import makeRegexTasks57#from dreamcoder.domains.regex import main as regex_main58from dreamcoder.domains.logo import logoPrimitives59from dreamcoder.domains.logo import makeLogoTasks60from dreamcoder.domains.logo import main as logo_main61from dreamcoder.domains.list import listPrimitives62from dreamcoder.domains.list import makeListTasks63from dreamcoder.domains.list import main as list_main64from dreamcoder.domains.arithmetic import arithmeticPrimitives65from dreamcoder.domains.text import textPrimitives66from dreamcoder.domains.text import makeTextTasks67from dreamcoder.domains.text import main as text_main68 69sys.modules['differentiation'] = differentiation70sys.modules['ec'] = dreamcoder71sys.modules['enumeration'] = enumeration72sys.modules['fragmentGrammar'] = fragmentGrammar73sys.modules['fragmentUtilities'] = fragmentUtilities74sys.modules['frontier'] = frontier75sys.modules['grammar'] = grammar76sys.modules['likelihoodModel'] = likelihoodModel77sys.modules['program'] = program78try: sys.modules['recognition'] = recognition79except: pass80sys.modules['task'] = task81sys.modules['taskBatcher'] = taskBatcher82sys.modules['type'] = type83sys.modules['utilities'] = utilities84sys.modules['vs'] = vs85sys.modules['algolispPrimitives'] = algolispPrimitives86sys.modules['RobustFillPrimitives'] = RobustFillPrimitives87sys.modules['napsPrimitives'] = napsPrimitives88sys.modules['makeTowerTasks'] = makeTowerTasks89sys.modules['towerPrimitives'] = towerPrimitives90sys.modules['tower_common'] = tower_common91#sys.modules['tower'] = tower_main92sys.modules['groundtruthRegexes'] = groundtruthRegexes93sys.modules['regexPrimitives'] = regexPrimitives94sys.modules['makeRegexTasks'] = makeRegexTasks95#sys.modules['regexes'] = regex_main96sys.modules['deepcoderPrimitives'] = deepcoderPrimitives97sys.modules['logoPrimitives'] = logoPrimitives98sys.modules['makeLogoTasks'] = makeLogoTasks99#sys.modules['logo'] = logo_main100sys.modules['listPrimitives'] = listPrimitives101sys.modules['makeListTasks'] = makeListTasks102#sys.modules['list'] = list_main103sys.modules['arithmeticPrimitives'] = arithmeticPrimitives104sys.modules['textPrimitives'] = textPrimitives105sys.modules['makeTextTasks'] = makeTextTasks106#sys.modules['text'] = text_main107sys.modules['primitiveGraph'] = primitiveGraph108