Quick Reference


Start a new project

project = signac.init_project('MyProject')
$ mkdir my_project
$ cd my_project
$ signac init MyProject
Initialized project 'MyProject'.

Open a job

project = signac.get_project()

with project.open_job({'a': 0}) as job:
    # do your job...

 with project.open_job(id='9bfd29df07674bc4aa960cf661b5acd2') as job:
    # do your job...
$ signac job '{"a": 0}'
$ signac job --workspace '{"a": 0}'
$ signac statepoint 9bfd29df07674bc4aa960cf661b5acd2
{"a": 0}

Find jobs

# Iterate over all jobs in the data space:
for job in project.find_jobs():
    # ...

# Iterate over a filtered subset:
for job in project.find_jobs({'a': 0}):
    # ...
# Find all jobs:
$ signac find

# Find a filtered subset:
$ signac find '{"a": 0}'

Index project data

  1. Use the index() method:

    for doc in project.index():
  2. Use the signac index function:

    $ signac index
  3. Define a custom crawler for example for a signac_access.py module:


Database Integration

Access a database

db = signac.get_database('my_database')

Export an index to a database collection

db = signac.get_database('mydb')
signac.contrib.export(project.index(), db.index)  # or export_pymongo()

Search a database collection

Example for a collection named index:

# a > 0
docs = db.index.find({'a': {'$gt': 0}})

# a = 2
doc = db.index.find_one({'a': 2})

Access data using an index

Access files using an index with signac.fetch() and signac.fetch_one():

docs = db.index.find({'a': 0, 'format': {'$regex': 'TextFile'}})
for doc in docs:
    with signac.fetch_one(doc) as file: