generate a suitable file name for the experiment
192035
def generate_file_name(self):
        """"""
        if not self.project:
            raise UnderDefined("project name not given")

        out_data_dir = prms.Paths.outdatadir
        project_dir = os.path.join(out_data_dir, self.project)
        file_name = "cellpy_batch_%s.json" % self.name
        self.file_name = os.path.join(project_dir, file_name)
42520
def load_experiment(folder, return_path=False):
    '''
    '''
    fullpath = os.path.abspath(folder)
    config = "%s/config.json" %(fullpath)
    if not os.path.exists(config):
        bot.error("config.json could not be found in %s" %(folder))
        config = None
    if return_path is False and config is not None:
        config = read_json(config)
    return config
50614
def gen_filename(endpoint):
    
    now = datetime.now().strftime('%Y%m%d_%H%M%S%f')[:-4]
    base = endpoint.split('://', 1)[1]
    if base.startswith('localhost:'):
        base = gethostname().split('.')[0] + base[9:]
    base = base.replace(':', '_').replace('/', '_')
    return '{}_{}.h5'.format(base, now)
291388
def _workout_filename(filename):
    '''
    
    '''
    if os.path.isfile(filename) or filename == '/':
        if filename == '/':
            filename = None
        return filename
    else:
        return _workout_filename(os.path.dirname(filename))
1335596
def create_file(self, name: str, generate_unique_name: bool = False):
        '''
        
        '''
        def enumerate_name():
            yield name
            index = 0
            while True:
                index += 1
                yield f'{name} ({index})'
        for n in enumerate_name():
            path = os.path.join(self._path, n)
            if os.path.exists(path):
                if not generate_unique_name:
                    raise FileExistsError
            return FileInfo(path)
5168
public function generateFilename(): string
    {
        $options = $this->provider->getOptions();

        $options["text"] = $this->text;

        $data = serialize($options);

        return md5($data) . "." . $this->provider->getFormat();
    }
1060067
def filename(self):
        """"""
        if self._filename is None:
            if os.path.splitext(self.destination)[1]:
                # If the filename has been given make use of it
                target_file = self.destination
            else:
                # Otherwise create it from the build details
                target_file = os.path.join(self.destination,
                                           self.build_filename(self.binary))

            self._filename = os.path.abspath(target_file)

        return self._filename
878630
def get_experiment_fn(args):
  

  def get_experiment(output_dir):
    # Merge schema, input features, and transforms.
    train_config = util.merge_metadata(args.preprocess_output_dir,
                                       args.transforms_file)

    # Get the model to train.
    estimator = util.get_estimator(output_dir, train_config, args)

    # Save a copy of the scehma and input to the model folder.
    schema_file = os.path.join(args.preprocess_output_dir, util.SCHEMA_FILE)

    # Make list of files to save with the trained model.
    additional_assets = {'features.json': args.transforms_file,
                         util.SCHEMA_FILE: schema_file}
    if util.is_classification_model(args.model_type):
      target_name = train_config['target_column']
      vocab_file_name = util.CATEGORICAL_ANALYSIS % target_name
      vocab_file_path = os.path.join(
          args.preprocess_output_dir, vocab_file_name)
      assert file_io.file_exists(vocab_file_path)
      additional_assets[vocab_file_name] = vocab_file_path

    export_strategy_target = util.make_export_strategy(
        train_config=train_config,
        args=args,
        keep_target=True,
        assets_extra=additional_assets)
    export_strategy_notarget = util.make_export_strategy(
        train_config=train_config,
        args=args,
        keep_target=False,
        assets_extra=additional_assets)

    input_reader_for_train = get_reader_input_fn(
        train_config=train_config,
        preprocess_output_dir=args.preprocess_output_dir,
        model_type=args.model_type,
        data_paths=args.train_data_paths,
        batch_size=args.train_batch_size,
        shuffle=True,
        num_epochs=args.num_epochs)

    input_reader_for_eval = get_reader_input_fn(
        train_config=train_config,
        preprocess_output_dir=args.preprocess_output_dir,
        model_type=args.model_type,
        data_paths=args.eval_data_paths,
        batch_size=args.eval_batch_size,
        shuffle=False,
        num_epochs=1)

    return tf.contrib.learn.Experiment(
        estimator=estimator,
        train_input_fn=input_reader_for_train,
        eval_input_fn=input_reader_for_eval,
        train_steps=args.max_steps,
        export_strategies=[export_strategy_target, export_strategy_notarget],
        min_eval_frequency=args.min_eval_frequency,
        eval_steps=None,
    )

  # Return a function to create an Experiment.
  return get_experiment
850072
def get_experiment_image_info(experiment: 'Experiment') -> Tuple[str, str]:
    """"""
    project_name = experiment.project.name
    repo_name = project_name

    image_name = '{}/{}'.format(conf.get('REGISTRY_URI'), repo_name)
    image_tag = experiment.code_reference.commit
    return image_name, image_tag
348192
def generate_folder_names(self):
        """"""
        self.project_dir = os.path.join(prms.Paths.outdatadir, self.project)
        self.batch_dir = os.path.join(self.project_dir, self.name)
        self.raw_dir = os.path.join(self.batch_dir, "raw_data")
436078
def build_filename(self, binary):
        """"""
        try:
            # Get exact timestamp of the build to build the local file name
            folder = self.builds[self.build_index]
            timestamp = re.search(r'([\d\-]+)-\D.*', folder).group(1)
        except Exception:
            # If it's not available use the build's date
            timestamp = self.date.strftime('%Y-%m-%d')

        return '%(TIMESTAMP)s-%(BRANCH)s-%(NAME)s' % {
            'TIMESTAMP': timestamp,
            'BRANCH': self.branch,
            'NAME': binary}
1133159
def _gen_file_name(self):
        '''
        
        '''
        date = datetime.datetime.now()
        dt = "{}-{}-{}-{}-{}-{}-{}".format(str(date.year),str(date.month),str(date.day),str(date.hour),str(date.minute),str(date.second),str(random.randint(0,10000)))
        return self._output_filename_pattern.format(dt)
930486
def filename(self, prefix='', suffix='', extension='.py'):
        """"""
        return BASE_NAME.format(prefix, self.num, suffix, extension)
459604
def gen_experiment_id(n=10):
    
    chrs = 'abcdefghijklmnopqrstuvwxyz'
    inds = np.random.randint(0,len(chrs), size=n)
    return ''.join([chrs[i] for i in inds])
787304
def gen_files(path, prefix="_"):
    "  "

    if op.isdir(path):
        for name in listdir(path):
            fpath = op.join(path, name)
            if is_parsed_file(fpath):
                yield op.abspath(fpath)

    elif is_parsed_file(path):
        yield op.abspath(path)
188402
def _generate_filenames(sources):
    

    for source in sources:

        if os.path.isdir(source):
            for path, dirlist, filelist in os.walk(source):
                for fname in filelist:
                    if nmrstarlib.VERBOSE:
                        print("Processing file: {}".format(os.path.abspath(fname)))
                    if GenericFilePath.is_compressed(fname):
                        if nmrstarlib.VERBOSE:
                            print("Skipping compressed file: {}".format(os.path.abspath(fname)))
                        continue
                    else:
                        yield os.path.join(path, fname)

        elif os.path.isfile(source):
            yield source

        elif GenericFilePath.is_url(source):
            yield source

        elif source.isdigit():
            try:
                urlopen(nmrstarlib.BMRB_REST + source)
                yield nmrstarlib.BMRB_REST + source
            except HTTPError:
                urlopen(nmrstarlib.PDB_REST + source + ".cif")
                yield nmrstarlib.PDB_REST + source + ".cif"

        elif re.match("[\w\d]{4}", source):
            yield nmrstarlib.PDB_REST + source + ".cif"

        else:
            raise TypeError("Unknown file source.")
507337
def generate_file(fname, ns_func, dest_dir="."):
    """"""
    with open(pjoin(root, 'buildutils', 'templates', '%s' % fname), 'r') as f:
        tpl = f.read()
    out = tpl.format(**ns_func())
    dest = pjoin(dest_dir, fname)
    info("generating %s from template" % dest)
    with open(dest, 'w') as f:
        f.write(out)