-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #551 from austin-hilberg/master
Documentation content additions and revisions for M2
- Loading branch information
Showing
31 changed files
with
247 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
.. code-block:: python | ||
>>> schema.external_table.delete_garbage() | ||
Use ``dj.config`` for configuration. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
.. code-block:: python | ||
This is done by saving the path in the ``cache`` key of the DataJoint configuration dictionary: | ||
|
||
>>> schema.external_table.clean_store('external-name') | ||
.. code-block:: python | ||
dj.config['cache'] = '/temp/dj-cache' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.. code-block:: python | ||
>>> schema.external_table.delete_garbage() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.. code-block:: python | ||
>>> schema.external_table.clean_store('external-name') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
The ``populate`` method accepts a number of optional arguments that provide more features and allow greater control over the method's behavior. | ||
|
||
- ``restrictions`` - A list of restrictions, restricting as ``(tab.key_source & AndList(restrictions)) - tab.proj()``. | ||
Here ``target`` is the table to be populated, usually ``tab`` itself. | ||
- ``suppress_errors`` - If ``True``, encountering an error will cancel the current ``make`` call, log the error, and continue to the next ``make`` call. | ||
Error messages will be logged in the job reservation table (if ``reserve_jobs`` is ``True``) and returned as a list. | ||
See also ``return_exception_objects`` and ``reserve_jobs``. | ||
Defaults to ``False``. | ||
- ``return_exception_objects`` - If ``True``, error objects are returned instead of error messages. | ||
This applies only when ``suppress_errors`` is ``True``. | ||
Defaults to ``False``. | ||
- ``reserve_jobs`` - If ``True``, reserves job to indicate to other distributed processes. | ||
The job reservation table may be access as ``schema.jobs``. | ||
Errors are logged in the jobs table. | ||
Defaults to ``False``. | ||
- ``order`` - The order of execution, either ``"original"``, ``"reverse"``, or ``"random"``. | ||
Defaults to ``"original"``. | ||
- ``display_progress`` - If ``True``, displays a progress bar. | ||
Defaults to ``False``. | ||
- ``limit`` - If not ``None``, checks at most this number of keys. | ||
Defaults to ``None``. | ||
- ``max_calls`` - If not ``None``, populates at most this many keys. | ||
Defaults to ``None``, which means no limit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
The method ``table.progress`` reports how many ``key_source`` entries have been populated and how many remain. | ||
Two optional parameters allow more advanced use of the method. | ||
A parameter of restriction conditions can be provided, specifying which entities to consider. | ||
A Boolean parameter ``display`` (default is ``True``) allows disabling the output, such that the numbers of remaining and total entities are returned but not printed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A custom key source can be configured by setting the ``key_source`` property within a table class, after the ``definition`` string. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.. code-block:: python | ||
@schema | ||
class EEG(dj.Imported): | ||
definition = """ | ||
-> Recording | ||
--- | ||
sample_rate : float | ||
eeg_data : longblob | ||
""" | ||
key_source = Recording & 'recording_type = "EEG"' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
.. code-block:: python | ||
@schema | ||
class Mouse(dj.Manual): | ||
definition = """ | ||
mouse_name : varchar(64) | ||
--- | ||
mouse_dob : datetime | ||
""" | ||
@schema | ||
class MouseDeath(dj.Manual): | ||
definition = """ | ||
-> Mouse | ||
--- | ||
death_date : datetime | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.. code-block:: python | ||
@schema | ||
class EEGRecording(dj.Manual): | ||
definition = """ | ||
-> Session | ||
eeg_recording_id : int | ||
--- | ||
eeg_system : varchar(64) | ||
num_channels : int | ||
""" | ||
@schema | ||
class ChannelData(dj.Imported): | ||
definition = """ | ||
-> EEGRecording | ||
channel_idx : int | ||
--- | ||
channel_data : longblob | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. code-block:: python | ||
@schema | ||
class Mouse(dj.Manual): | ||
definition = """ | ||
mouse_name : varchar(64) | ||
--- | ||
mouse_dob : datetime | ||
""" | ||
@schema | ||
class SubjectGroup(dj.Manual): | ||
definition = """ | ||
group_number : int | ||
--- | ||
group_name : varchar(64) | ||
""" | ||
class GroupMember(dj.Part): | ||
definition = """ | ||
-> master | ||
-> Mouse | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.. code-block:: python | ||
@schema | ||
class RecordingModality(dj.Lookup): | ||
definition = """ | ||
modality : varchar(64) | ||
""" | ||
@schema | ||
class MultimodalSession(dj.Manual): | ||
definition = """ | ||
-> Session | ||
modes : int | ||
""" | ||
class SessionMode(dj.Part): | ||
definition = """ | ||
-> master | ||
-> RecordingModality | ||
""" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
|
||
The table is created at the time of the class definition. | ||
In fact, it is one of the jobs performed by the decorator ``@schema`` of the class. | ||
Users do not need to do anything special to have a table created in the database. | ||
Tables are created at the time of class definition. | ||
In fact, table creation on the database is one of the jobs performed by the decorator ``@schema`` of the class. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
|
||
Dropping part tables | ||
-------------------- | ||
|
||
A :ref:`part table <master-part>` is usually removed as a consequence of calling ``drop`` on its master table. | ||
To enforce this workflow, calling ``drop`` directly on a part table produces an error. | ||
In some cases, it may be necessary to override this behavior. | ||
To remove a part table without removing its master, use the argument ``force=True``. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
The function ``create_virtual_module`` of the ``dj.schema`` class provides access to virtual modules. | ||
It creates a python module with the given name from the name of a schema on the server, automatically adds classes to it corresponding to the tables in the schema. | ||
|
||
The function can take several parameters: | ||
|
||
``module_name``: displayed module name. | ||
|
||
``schema_name``: name of the database in MySQL. | ||
|
||
``create_schema``: if ``True``, create the schema on the database server if it does not already exist; if ``False`` (default), raise an error when the schema is not found. | ||
|
||
``create_tables``: if ``True``, ``module.schema`` can be used as the decorator for declaring new classes; if ``False``, such use will raise an error stating that the module is intend only to work with existing tables. | ||
|
||
The function returns the Python module containing classes from the schema object with all the table classes already declared inside it. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
.. code-block:: python | ||
# Server-side inserts are faster... | ||
phase_two.Protocol.insert(phase_one.Protocol) | ||
# ...than fetching before inserting | ||
protocols = phase_one.Protocol.fetch() | ||
phase_two.Protocol.insert(protocols) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
|
||
Entities in a :ref:`part table <master-part>` are usually removed as a consequence of calling ``delete`` on the master table. | ||
To enforce this workflow, calling ``delete`` directly on a part table produces an error. | ||
In some cases, it may be necessary to override this behavior. | ||
To remove entities from a part table without calling ``delete`` master, use the argument ``force=True``. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
|
||
* another table | ||
* a query expression | ||
* a mapping, e.g. ``dict`` | ||
* an expression in a character string | ||
* a collection of conditions as a ``list`` or ``tuple`` | ||
* a collection of conditions as a ``list``, ``tuple``, or Pandas ``DataFrame`` | ||
* a Boolean expression (``True`` or ``False``) | ||
* an ``AndList`` | ||
* a ``Not`` object | ||
|
||
* a query expression |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
|
||
A collection can be a list or tuple. | ||
|
||
.. code-block:: python | ||
# a list: | ||
cond_list = ['first_name = "Aaron"', 'last_name = "Aaronson"'] | ||
# All the sessions performed by Alice | ||
Session & 'user = "Alice"' | ||
# a tuple: | ||
cond_tuple = ('first_name = "Aaron"', 'last_name = "Aaronson"') | ||
# All the experiments at least one minute long | ||
Experiment & 'duration >= 60' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,15 @@ | ||
|
||
.. code-block:: python | ||
A collection can be a list, a tuple, or a Pandas ``DataFrame``. | ||
|
||
Student() & ['first_name = "Aaron"', 'last_name = "Aaronson"'] | ||
.. code-block:: python | ||
.. figure:: ../_static/img/python_collection.png | ||
:align: center | ||
:alt: restriction by collection | ||
# a list: | ||
cond_list = ['first_name = "Aaron"', 'last_name = "Aaronson"'] | ||
Restriction by a collection, returning any entities matching any condition in the collection. | ||
# a tuple: | ||
cond_tuple = ('first_name = "Aaron"', 'last_name = "Aaronson"') | ||
# a dataframe: | ||
import pandas as pd | ||
cond_frame = pd.DataFrame( | ||
data={'first_name': ['Aaron'], 'last_name': ['Aaronson']}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
|
||
``A & True`` and ``A - False`` are equivalent to ``A``. | ||
``A & False`` and ``A - True`` are empty. | ||
.. code-block:: python | ||
Student() & ['first_name = "Aaron"', 'last_name = "Aaronson"'] | ||
.. figure:: ../_static/img/python_collection.png | ||
:align: center | ||
:alt: restriction by collection | ||
|
||
Restriction by a collection, returning all entities matching any condition in the collection. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,4 @@ | ||
|
||
Restriction by an ``AndList`` | ||
----------------------------- | ||
|
||
The special function ``dj.AndList`` represents logical conjunction (logical AND). | ||
Restriction of table ``A`` by an ``AndList`` will return all entities in ``A`` that meet *all* of the conditions in the list. | ||
``A & dj.AndList([c1, c2, c3])`` is equivalent to ``A & c1 & c2 & c3``. | ||
Usually, it is more convenient to simply write out all of the conditions, as ``A & c1 & c2 & c3``. | ||
However, when a list of conditions has already been generated, the list can simply be passed as the argument to ``dj.AndList``. | ||
|
||
Restriction of table ``A`` by an empty ``AndList``, as in ``A & dj.AndList([])``, will return all of the entities in ``A``. | ||
Exclusion by an empty ``AndList`` will return no entities. | ||
|
||
Restriction by a ``Not`` object | ||
------------------------------- | ||
|
||
The special function ``dj.Not`` represents logical negation, such that ``A & dj.Not(cond)`` is equivalent to ``A - cond``. | ||
``A & True`` and ``A - False`` are equivalent to ``A``. | ||
|
||
``A & False`` and ``A - True`` are empty. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
Restriction by an ``AndList`` | ||
----------------------------- | ||
|
||
The special function ``dj.AndList`` represents logical conjunction (logical AND). | ||
Restriction of table ``A`` by an ``AndList`` will return all entities in ``A`` that meet *all* of the conditions in the list. | ||
``A & dj.AndList([c1, c2, c3])`` is equivalent to ``A & c1 & c2 & c3``. | ||
Usually, it is more convenient to simply write out all of the conditions, as ``A & c1 & c2 & c3``. | ||
However, when a list of conditions has already been generated, the list can simply be passed as the argument to ``dj.AndList``. | ||
|
||
Restriction of table ``A`` by an empty ``AndList``, as in ``A & dj.AndList([])``, will return all of the entities in ``A``. | ||
Exclusion by an empty ``AndList`` will return no entities. | ||
|
||
Restriction by a ``Not`` object | ||
------------------------------- | ||
|
||
The special function ``dj.Not`` represents logical negation, such that ``A & dj.Not(cond)`` is equivalent to ``A - cond``. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.. code-block:: python | ||
query = Session & 'user = "Alice"' | ||
Experiment & query |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.