当前位置: 首页>>代码示例>>Python>>正文


Python projects.load_project函数代码示例

本文整理汇总了Python中sumatra.projects.load_project函数的典型用法代码示例。如果您正苦于以下问题:Python load_project函数的具体用法?Python load_project怎么用?Python load_project使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了load_project函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: determine_project

def determine_project(sumatra_options):
    if 'project_dir' in sumatra_options and sumatra_options['project_dir']:
        prj = load_project(sumatra_options['project_dir'])
    else:
        try:
            prj = load_project()
        except IOError:
            prj = None
    return prj
开发者ID:Felix11H,项目名称:sumatra,代码行数:9,代码来源:utils.py

示例2: get_context_data

    def get_context_data(self, **kwargs):
        context = super(ProjectListView, self).get_context_data(**kwargs)
        projects = self.get_queryset()

        context['active'] = 'List of projects'
        if not len(projects):
            context['project_name'] = load_project().name
            if not load_project().default_executable:  # empty project: without any records inside
                context['show_modal'] = True
        else:
            context['project_name'] = projects[0]
        return context
开发者ID:evgenjevich,项目名称:sumatra,代码行数:12,代码来源:views.py

示例3: delete

def delete(argv):
    """Delete records or records with a particular tag from a project."""
    usage = "%(prog)s delete [options] LIST"
    description = dedent("""\
      LIST should be a space-separated list of labels for individual records or
      of tags. If it contains tags, you must set the --tag/-t option (see below).
      The special value "last" allows you to delete the most recent simulation/analysis.
      If you want to delete all records, just delete the .smt directory and use
      smt init to create a new, empty project.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('labels', metavar='LIST', nargs="+", help="a space-separated list of labels for individual records or of tags")
    parser.add_argument('-t', '--tag', action='store_true',
                        help="interpret LIST as containing tags. Records with any of these tags will be deleted.")
    parser.add_argument('-d', '--data', action='store_true',
                        help="also delete any data associated with the record(s).")
    args = parser.parse_args(argv)

    project = load_project()

    if args.tag:
        for tag in args.labels:
            n = project.delete_by_tag(tag, delete_data=args.data)
            print("%s records deleted." % n)
    else:
        for label in args.labels:
            if label == 'last':
                label = project.most_recent().label
            try:
                project.delete_record(label, delete_data=args.data)
            except Exception:  # could be KeyError or DoesNotExist: should create standard NoSuchRecord or RecordDoesNotExist exception
                warnings.warn("Could not delete record '%s' because it does not exist" % label)
开发者ID:Felix11H,项目名称:sumatra,代码行数:32,代码来源:commands.py

示例4: comment

def comment(argv):
    """Add a comment to an existing record."""
    usage = "%(prog)s comment [options] [LABEL] COMMENT"
    description = dedent("""\
      This command is used to describe the outcome of the simulation/analysis.
      If LABEL is omitted, the comment will be added to the most recent experiment.
      If the '-f/--file' option is set, COMMENT should be the name of a file
      containing the comment, otherwise it should be a string of text.
      By default, comments will be appended to any existing comments.
      To overwrite existing comments, use the '-r/--replace flag.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('label', nargs='?', metavar='LABEL', help="the record to which the comment will be added")
    parser.add_argument('comment', help="a string of text, or the name of a file containing the comment.")
    parser.add_argument('-r', '--replace', action='store_true',
                        help="if this flag is set, any existing comment will be overwritten, otherwise, the new comment will be appended to the end, starting on a new line")
    parser.add_argument('-f', '--file', action='store_true',
                        help="interpret COMMENT as the path to a file containing the comment")
    args = parser.parse_args(argv)

    if args.file:
        f = open(args.comment, 'r')
        comment = f.read()
        f.close()
    else:
        comment = args.comment

    project = load_project()
    label = args.label or project.most_recent().label
    project.add_comment(label, comment, replace=args.replace)
开发者ID:Felix11H,项目名称:sumatra,代码行数:30,代码来源:commands.py

示例5: repeat

def repeat(argv):
    """Re-run a previous simulation or analysis."""
    usage = "%(prog)s repeat LABEL"
    description = dedent("""\
        Re-run a previous simulation/analysis under (in theory) identical
        conditions, and check that the results are unchanged.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('original_label', metavar='LABEL', help='label of record to be repeated')
    parser.add_argument('-l', '--label', metavar='NEW_LABEL', help="specify a label for the new experiment. If no label is specified, one will be generated automatically.")

    args = parser.parse_args(argv)
    original_label = args.original_label
    project = load_project()
    new_label, original_label = project.repeat(original_label, args.label)
    diff = project.compare(original_label, new_label)
    if diff:
        formatter = get_diff_formatter()(diff)
        msg = ["The new record does not match the original. It differs as follows.",
               formatter.format('short'),
               "run smt diff --long %s %s to see the differences in detail." % (original_label, new_label)]
        msg = "\n".join(msg)
    else:
        msg = "The new record exactly matches the original."
    print(msg)
    project.add_comment(new_label, msg)
开发者ID:Felix11H,项目名称:sumatra,代码行数:26,代码来源:commands.py

示例6: sync

def sync(argv):
    usage = "%(prog)s sync PATH1 [PATH2]"
    description = dedent("""\
        Synchronize two record stores. If both PATH1 and PATH2 are given, the
        record stores at those locations will be synchronized. If only PATH1 is
        given, and the command is run in a directory containing a Sumatra
        project, only that project's records be synchronized with the store at
        PATH1. Note that PATH1 and PATH2 may be either filesystem paths or URLs.
        """)  # need to say what happens if the sync is incomplete due to label collisions
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('path1')
    parser.add_argument('path2', nargs='?')
    args = parser.parse_args(argv)

    store1 = get_record_store(args.path1)
    if args.path2:
        store2 = get_record_store(args.path2)
        collisions = store1.sync_all(store2)
    else:
        project = load_project()
        store2 = project.record_store
        collisions = store1.sync(store2, project.name)

    if collisions:
        print("Synchronization incomplete: there are two records with the same name for the following: %s" % ", ".join(collisions))
        sys.exit(1)
开发者ID:Felix11H,项目名称:sumatra,代码行数:27,代码来源:commands.py

示例7: migrate

def migrate(argv):
    usage = "%(prog)s migrate [options]"
    description = dedent("""\
        If you have moved your data files to a new location, update the record
        store to reflect the new paths.
        """)
    # might also want to update the repository upstream
    # should we keep a history of such changes?
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('-d', '--datapath', metavar='PATH', help="modify the path to the directory in which your results are stored.")
    parser.add_argument('-i', '--input', metavar='PATH', help="modify the path to the directory in which your input data files are stored.")
    parser.add_argument('-A', '--archive', metavar='PATH', help="modify the directory in which your results are archived.")
    parser.add_argument('-M', '--mirror', metavar='URL', help="modify the URL at which your data files are mirrored.")
    args = parser.parse_args(argv)
    project = load_project()
    field_map = {
        "datapath": "datastore.root",
        "input": "input_datastore.root",
        "archive": "datastore.archive",
        "mirror": "datastore.mirror_base_url"
    }

    if not any(vars(args).values()):
        warnings.warn(
            "Command 'smt migrate' had no effect. Please provide at least one "
            "argument. (Run 'smt help migrate' for help.)")
    else:
        for option_name, field in field_map.items():
            value = getattr(args, option_name)
            if value:
                project.record_store.update(project.name, field, value)
开发者ID:Felix11H,项目名称:sumatra,代码行数:32,代码来源:commands.py

示例8: list

def list(argv):  # add 'report' and 'log' as aliases
    """List records belonging to the current project."""
    usage = "%(prog)s list [options] [TAGS]"
    description = dedent("""\
      If TAGS (optional) is specified, then only records tagged with all the tags in TAGS
      will be listed.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('tags', metavar='TAGS', nargs='*')
    parser.add_argument('-l', '--long', action="store_const", const="long",
                        dest="mode", default="short",
                        help="prints full information for each record"),
    parser.add_argument('-T', '--table', action="store_const", const="table",
                        dest="mode", help="prints information in tab-separated columns")
    parser.add_argument('-f', '--format', metavar='FMT', choices=['text', 'html', 'latex', 'shell', 'json'],
                        default='text',
                        help="FMT can be 'text' (default), 'html', 'json', 'latex' or 'shell'.")
    parser.add_argument('-r', '--reverse', action="store_true", dest="reverse", default=False,
                        help="list records in reverse order (default: newest first)")
    parser.add_argument('-m', '--main_file', help="filter list of records by main file")
    parser.add_argument('-P', '--parameter_table', action="store_const", const="parameter_table",
                        dest="mode", help="list records with parameter values")
    args = parser.parse_args(argv)

    project = load_project()
    if os.path.exists('.smt'):
        with open('.smt/labels', 'w') as f:
            f.write('\n'.join(project.get_labels()))

    kwargs = {'tags':args.tags, 'mode':args.mode, 'format':args.format, 'reverse':args.reverse}
    if args.main_file is not None: kwargs['main_file__startswith'] = args.main_file
    print(project.format_records(**kwargs))
开发者ID:GregorWautischer,项目名称:sumatra,代码行数:32,代码来源:commands.py

示例9: list

def list(argv):  # add 'report' and 'log' as aliases
    """List records belonging to the current project."""
    usage = "%(prog)s list [options] [TAGS]"
    description = dedent("""\
      If TAGS (optional) is specified, then only records tagged with all the tags in TAGS
      will be listed.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    parser.add_argument('tags', metavar='TAGS', nargs='*')
    parser.add_argument('-l', '--long', action="store_const", const="long",
                        dest="mode", default="short",
                        help="prints full information for each record"),
    parser.add_argument('-T', '--table', action="store_const", const="table",
                        dest="mode", help="prints information in tab-separated columns")
    parser.add_argument('-f', '--format', metavar='FMT', choices=['text', 'html', 'latex', 'shell', 'json'],
                        default='text',
                        help="FMT can be 'text' (default), 'html', 'json', 'latex' or 'shell'.")
    parser.add_argument('-r', '--reverse', action="store_true", dest="reverse", default=False,
                        help="list records in reverse order (default: newest first)"),
    args = parser.parse_args(argv)

    project = load_project()
    if os.path.exists('.smt'):
        f = open('.smt/labels', 'w')
        f.writelines(project.format_records(tags=None, mode='short', format='text', reverse=False))
        f.close()
    print(project.format_records(tags=args.tags, mode=args.mode, format=args.format, reverse=args.reverse))
开发者ID:Felix11H,项目名称:sumatra,代码行数:27,代码来源:commands.py

示例10: export

def export(argv):
    usage = "%(prog)s export"
    description = dedent("""\
        Export a Sumatra project and its records to JSON. This is needed before running upgrade.""")
    parser = ArgumentParser(usage=usage,
                            description=description)
    args = parser.parse_args(argv)
    project = load_project()
    project.export()
开发者ID:Felix11H,项目名称:sumatra,代码行数:9,代码来源:commands.py

示例11: settings

def settings(request, project):
    ''' Only one of the following parameter can be True
    web_settings['saveSettings'] == True: save the settings in .smt/project
    web_settings['web'] == True: send project.web_settings to record_list.html
    web_settings['sumatra'] = True: send some spacific settings to record_list.html (they will
    be used in the popup window for the new record as the default values
    '''
    web_settings = {'display_density':request.POST.get('display_density', False),
                    'nb_records_per_page':request.POST.get('nb_records_per_page', False),
                    'table_HideColumns': request.POST.getlist('table_HideColumns[]'),
                    'saveSettings':request.POST.get('saveSettings', False), 
                    'web':request.POST.get('web', False), 
                    'sumatra':request.POST.get('sumatra', False) 
                    }
    nbCols = 14  # total number of columns
    sim_list = models.Record.objects.filter(project__id=project).order_by('-timestamp')
    project_loaded = load_project() 
    if web_settings['saveSettings']:
        if len(web_settings['table_HideColumns']) == 0:  # empty set (all checkboxes are checked)
            project_loaded.web_settings['table_HideColumns'] = []
        try:
            project_loaded.web_settings
        except(AttributeError, KeyError): # project doesn't have web_settings yet
            # upgrading of .smt/project: new supplementary settings entries
            project_loaded.web_settings = init_websettings()   
        for key, item in web_settings.iteritems():
            if item:
                project_loaded.web_settings[key] = item
        project_loaded.save()
        # repetition of code for list_records !!!
        nb_per_page = int(web_settings['nb_records_per_page'])
        paginator = Paginator(sim_list, nb_per_page)
        page_list = paginator.page(1)
        nbCols_actual = nbCols - len(web_settings['table_HideColumns'])
        head_width = '%s%s' %(90.0/nbCols_actual, '%')
        if (nbCols_actual > 10):
            label_width = '150px'
        else:
            label_width = head_width
        dic = {'project_name': project,
               'settings':project_loaded.web_settings,
               'paginator':paginator,
               'object_list':page_list.object_list,
               'page_list':page_list,
               'width':{'head': head_width, 'label':label_width}}
        return render_to_response('content.html', dic)
    elif web_settings['web']: 
        return HttpResponse(simplejson.dumps(project.web_settings))
    elif web_settings['sumatra']:
        settings = {'execut':project.default_executable.path,
                    'mfile':project.default_main_file}
        return HttpResponse(simplejson.dumps(settings))
开发者ID:dcherian,项目名称:sumatra,代码行数:52,代码来源:views_old.py

示例12: info

def info(argv):
    """Print information about the current project."""
    usage = "%(prog)s info"
    description = "Print information about the current project."
    parser = ArgumentParser(usage=usage,
                            description=description)
    args = parser.parse_args(argv)
    try:
        project = load_project()
    except IOError as err:
        print(err)
        sys.exit(1)
    print(project.info())
开发者ID:Felix11H,项目名称:sumatra,代码行数:13,代码来源:commands.py

示例13: export_records

def export_records(output_file):
    store = load_recordstore()
    if minor_version < 3:
        patch_sumatra()
    f = open(output_file, "w")
    if minor_version == 1:
        json.dump([encode_record(record) for record in store.list(groups=None)], f, indent=2)
    else:
        project_name = projects.load_project().name
        if minor_version == 2:
            json.dump([encode_record(record) for record in store.list(project_name)], f, indent=2)
        else:
            f.write(store.export(project_name))
    f.close()
开发者ID:Felix11H,项目名称:sumatra,代码行数:14,代码来源:export.py

示例14: sumatra_start

def sumatra_start(repository, sumatra_db_path, results_path, working_dir, hg_username, sumatra_run_name, parameters):
    '''Clones the Omics Pipe repository from Bitbucket, creates a Sumatra project, and creates a Sumatra record for the current run'''
    print "sumatra_db_path is " + sumatra_db_path
    print type(sumatra_db_path)
    check_create_dir(sumatra_db_path)
    os.chdir(sumatra_db_path)
    repo1 = hgapi.Repo(repository)
    repo_path = sumatra_db_path +"/omics_pipe"
    repo= {"url":repo_path, 
           "type":"sumatra.versioncontrol._mercurial.MercurialRepository",
           "upstream":repository}
    executable= {"path":"",
                 "version": "",
                 "type":"sumatra.programs.PythonExecutable",
                 "options":"",
                 "name": "Python"}
    sumatra_launch_mode = {"working_directory": working_dir, "type": "sumatra.launch.SerialLaunchMode"}
    data_store1 = {"root":results_path, "type": "sumatra.datastore.filesystem.FileSystemDataStore"}
    database_path = sumatra_db_path + "/records/recordstore.db"
    record_store1 = {"db_file": database_path, "type": "sumatra.recordstore.django_store.DjangoRecordStore"}
    input_datastore1 = {"root": results_path, "type": "sumatra.datastore.filesystem.FileSystemDataStore"}
    while True:
        try:
            repo1.hg_clone(url = repository, path=repo_path)
            with open(repo_path + "/.hg/hgrc", "a") as myfile:
                myfile.write("[ui]\nusername= " + hg_username)         
            print "Omics pipe repository cloned to : " + repo_path
            break
        except hgapi.hgapi.HgException:
            print "Omics pipe repository already exists."
            break
    while True:
        try:
            Project(sumatra_run_name, default_repository=repo, default_executable=executable, 
                    default_launch_mode = sumatra_launch_mode, on_changed='store-diff',
                    data_store=data_store1, record_store=record_store1, input_datastore=input_datastore1)            
            print "Sumatra project created: " + sumatra_run_name + " in directory: " + sumatra_db_path
            break
        except Exception:
            print "Sumatra project already exists, loading project: " + sumatra_run_name
            break
    project = load_project(path=sumatra_db_path)
    print project
    sumatra_params = build_parameters(parameters)
    print sumatra_params
    os.chdir(repo_path)
    repo_main = "omics_pipe/main.py"
    record = project.new_record(parameters=sumatra_params, main_file=repo_main)
    print record
    return record,project
开发者ID:adammaikai,项目名称:OmicsPipe2.0,代码行数:50,代码来源:utils.py

示例15: smt_run

    def smt_run(self, line):
        args = parse_argstring(self.smt_run, line)

        global parameters
        if args.flush:
            parameters = build_parameters(args.parameters)
        else:
            parameters = globals().get('parameters',build_parameters(args.parameters))

        global save
        save = args.save

        if args.print:
            print(12*"-" + " Script " + 12*"-")
            with open(args.main_file, 'r') as f:
                script = f.readlines()
            f.closed
            print(''.join(script), end='')
            print(32*"-", end="\n\n")
            print(10*"-" + " Parameters " + 10*"-")
            print(parameters)
            print(32*"-", end="\n\n")

        if args.record is True:
            global record
            project = load_project()
            record = project.new_record(main_file=os.path.relpath(args.main_file),parameters=parameters)
            print("Record label for this run: '%s'" %record.label)

        start_time = time.time()
        execfile(args.main_file, globals(), parameters.as_dict())
        duration = time.time() - start_time

        if args.record is True:
            fname = "%s"%record.label
            if globals().has_key('data'):  np.savetxt("Data/%s.dat"%fname, data)
            if globals().has_key('fig'): fig.savefig("Data/%s.png"%fname)
            record.duration = duration
            record.output_data = record.datastore.find_new_data(record.timestamp)
            project.add_record(record)
            project.save()
            print("Data keys are [%s(%s [%s])"%(record.label, record.version, record.timestamp))

        elif save is True:
            fname = "%s_%s" %(time.strftime("%y%m%d-%H%M%S", time.gmtime(start_time)),
                os.path.splitext(os.path.basename(args.main_file))[0])
            if globals().has_key('data'): np.savetxt("%s.dat"%fname, data)                           # Save data
            if globals().has_key('fig'): fig.savefig("%s.png"%fname)
        print("Duration: %.2fs" %duration)
开发者ID:babsey,项目名称:sumatra_ipython,代码行数:49,代码来源:sumatramagic.py


注:本文中的sumatra.projects.load_project函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。