예제 #1
0
파일: run.py 프로젝트: SpringRi/phd
def main(argv):
    """Main entry point."""
    if len(argv) > 1:
        raise app.UsageError("Unknown arguments: '{}'.".format(' '.join(
            argv[1:])))

    start_time = time.time()
    instances = [
        clgen.Instance(p) for p in pbutil.FromFile(
            pathlib.Path(FLAGS.instances), clgen_pb2.Instances()).instance
    ]
    random.shuffle(instances)
    candidate_instances = collections.deque(instances)
    logging.info('Loaded %d instances in %s ms', len(candidate_instances),
                 humanize.intcomma(int((time.time() - start_time) * 1000)))

    while candidate_instances:
        instance = candidate_instances.popleft()
        with instance.Session():
            if IsEligible(instance):
                logging.info('Found an eligible candidate to work on')
                SampleModel(instance)
                PostprocessSampleCorpus(instance)
            else:
                logging.info('Candidate is ineligible')
                candidate_instances.append(instance)
                time.sleep(1)

    logging.info('Done.')
예제 #2
0
def GetInstancesConfig(
        instances: typing.List[clgen.Instance]) -> clgen_pb2.Instances:
    """Get an Instances proto from a list of instances."""
    config = clgen_pb2.Instances()
    config.instance.extend(instance.ToProto() for instance in instances)
    return config
예제 #3
0
def GetInstanceConfigs() -> clgen_pb2.Instances:
    """Get the list of CLgen instance configs to test."""
    instances = clgen_pb2.Instances()
    for _, config in LANGUAGES.items():
        instances.instance.extend(EnumerateLanguageInstanceConfigs(config))
    return instances