How to use the signac.common.config.load_config function in signac

To help you get started, we’ve selected a few signac examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github glotzerlab / signac / tests / test_shell.py View on Github external
def test_config_show(self):
        err = self.call('python -m signac config --local show'.split(), error=True).strip()
        assert 'Did not find a local configuration file' in err

        self.call('python -m signac init my_project'.split())
        out = self.call('python -m signac config --local show'.split()).strip()
        cfg = config.read_config_file('signac.rc')
        expected = config.Config(cfg).write()
        assert out.split(os.linesep) == expected

        out = self.call('python -m signac config show'.split()).strip()
        cfg = config.load_config()
        expected = config.Config(cfg).write()
        assert out.split(os.linesep) == expected

        out = self.call('python -m signac config --global show'.split()).strip()
        cfg = config.read_config_file(config.FN_CONFIG)
        expected = config.Config(cfg).write()
        assert out.split(os.linesep) == expected
github glotzerlab / signac / tests / test_job.py View on Github external
def setUp(self, request):
        self._tmp_dir = TemporaryDirectory(prefix='signac_')
        request.addfinalizer(self._tmp_dir.cleanup)
        self._tmp_pr = os.path.join(self._tmp_dir.name, 'pr')
        self._tmp_wd = os.path.join(self._tmp_dir.name, 'wd')
        os.mkdir(self._tmp_pr)
        self.config = signac.common.config.load_config()
        self.project = self.project_class.init_project(
            name='testing_test_project',
            root=self._tmp_pr,
            workspace=self._tmp_wd)

        warnings.filterwarnings('ignore', category=DeprecationWarning, module='signac')
github glotzerlab / signac / signac / contrib / configure.py View on Github external
def get_config(args, for_writing=False):
    try:
        if args._global:
            config_ = config.read_config_file(USER_GLOBAL)
        elif args.config:
            config_ = config.read_config_file(args.config)
        elif for_writing:
            config_ = config.read_config_file(USER_LOCAL)
        else:
            config_ = config.load_config()
    except FileNotFoundError:
        pass
    return config_
github glotzerlab / signac / signac / contrib / init_project.py View on Github external
def generate_config(args):
    global_config = load_config()
    if not args.workspace and global_config.get('workspace_dir') is None:
        args.workspace = DEFAULT_WORKSPACE
    if not args.storage and global_config.get('filestorage_dir') is None:
        args.storage = DEFAULT_STORAGE
    c_args = {
        'project':  args.project_name,
        'signac_version': args.signac_version,
    }
    if args.workspace:
        make_dir(args.workspace)
        c_args['workspace_dir'] = args.workspace
    if args.storage:
        make_dir(args.storage)
        c_args['filestorage_dir'] = args.storage
    if args.db_host:
        c_args['database_host'] = args.db_host
github glotzerlab / signac / signac / gui / gui.py View on Github external
def load_config(self):
        self.set_status("Loading config...")
        self.config = load_config()
        self.set_status("Done.", 3000)
github glotzerlab / signac / signac / contrib / project.py View on Github external
:type root: str
        :param search:
            If True, search for project configurations inside and above
            the specified root directory, otherwise only return projects
            with a root directory identical to the specified root argument.
        :type search: bool
        :param \*\*kwargs:
            Optional keyword arguments that are forwarded to the
            :class:`.Project` class constructor.
        :returns: The project handle.
        :rtype: :py:class:`~.Project`
        :raises LookupError: If no project configuration can be found.
        """
        if root is None:
            root = os.getcwd()
        config = load_config(root=root, local=False)
        if 'project' not in config or \
                (not search and os.path.realpath(config['project_dir']) != os.path.realpath(root)):
            raise LookupError(
                "Unable to determine project id for path '{}'.".format(os.path.abspath(root)))

        return cls(config=config, **kwargs)