Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test suite to remove unittest dependency in favor of pytest (feature/pytest) #70

Merged
merged 6 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 51 additions & 59 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,62 +30,54 @@ body.light-theme {
background-color: blue !important;
}

pre.light-theme .kn { color: #2838b0 !important } /* Keyword.Namespace */
pre.light-theme .kp { color: #2838b0 !important } /* Keyword.Pseudo */
pre.light-theme .kr { color: #2838b0 !important } /* Keyword.Reserved */
pre.light-theme .kt { color: #2838b0; font-style: italic !important } /* Keyword.Type */
pre.light-theme .m { color: #444444 !important } /* Literal.Number */
pre.light-theme .s { color: #b83838 !important } /* Literal.String */
pre.light-theme .na { color: #388038 !important } /* Name.Attribute */
pre.light-theme .nb { color: #388038 !important } /* Name.Builtin */
pre.light-theme .nc { color: #287088 !important } /* Name.Class */
pre.light-theme .no { color: #b85820 !important } /* Name.Constant */
pre.light-theme .nd { color: #287088 !important } /* Name.Decorator */
pre.light-theme .ni { color: #709030 !important } /* Name.Entity */
pre.light-theme .ne { color: #908828 !important } /* Name.Exception */
pre.light-theme .nf { color: #785840 !important } /* Name.Function */
pre.light-theme .nl { color: #289870 !important } /* Name.Label */
pre.light-theme .nn { color: #289870 !important } /* Name.Namespace */
pre.light-theme .nt { color: #2838b0 !important } /* Name.Tag */
pre.light-theme .nv { color: #b04040 !important } /* Name.Variable */
pre.light-theme .ow { color: #a848a8 !important } /* Operator.Word */
pre.light-theme .pm { color: #888888 !important } /* Punctuation.Marker */
pre.light-theme .w { color: #a89028 !important } /* Text.Whitespace */
pre.light-theme .mb { color: #444444 !important } /* Literal.Number.Bin */
pre.light-theme .mf { color: #444444 !important } /* Literal.Number.Float */
pre.light-theme .mh { color: #444444 !important } /* Literal.Number.Hex */
pre.light-theme .mi { color: #444444 !important } /* Literal.Number.Integer */
pre.light-theme .mo { color: #444444 !important } /* Literal.Number.Oct */
pre.light-theme .sa { color: #444444 !important } /* Literal.String.Affix */
pre.light-theme .sb { color: #b83838 !important } /* Literal.String.Backtick */
pre.light-theme .sc { color: #a848a8 !important } /* Literal.String.Char */
pre.light-theme .dl { color: #b85820 !important } /* Literal.String.Delimiter */
pre.light-theme .sd { color: #b85820; font-style: italic !important } /* Literal.String.Doc */
pre.light-theme .s2 { color: #b83838 !important } /* Literal.String.Double */
pre.light-theme .se { color: #709030 !important } /* Literal.String.Escape */
pre.light-theme .sh { color: #b83838 !important } /* Literal.String.Heredoc */
pre.light-theme .si { color: #b83838; text-decoration: underline !important } /* Literal.String.Interpol */
pre.light-theme .sx { color: #a848a8 !important } /* Literal.String.Other */
pre.light-theme .sr { color: #a848a8 !important } /* Literal.String.Regex */
pre.light-theme .s1 { color: #b83838 !important } /* Literal.String.Single */
pre.light-theme .ss { color: #b83838 !important } /* Literal.String.Symbol */
pre.light-theme .bp { color: #388038; font-style: italic !important } /* Name.Builtin.Pseudo */
pre.light-theme .fm { color: #b85820 !important } /* Name.Function.Magic */
pre.light-theme .vc { color: #b04040 !important } /* Name.Variable.Class */
pre.light-theme .vg { color: #908828 !important } /* Name.Variable.Global */
pre.light-theme .vi { color: #b04040 !important } /* Name.Variable.Instance */
pre.light-theme .vm { color: #b85820 !important } /* Name.Variable.Magic */
pre.light-theme .il { color: #444444 !important } /* Literal.Number.Integer.Long */
pre.light-theme .n { color: #444444 !important } /* Misc */
pre.light-theme .o { color: #444 !important } /* Misc */
pre.light-theme .p { color: #444 !important } /* Misc */
pre.light-theme .k { color: #a848a8 !important } /* Misc */
pre.light-theme .kc { color: #2838b0 !important } /* Misc */
pre.light-theme .go { color: #546E7A !important } /* Misc */
pre.light-theme .go { color: #546E7A !important } /* Misc */
pre.light-theme .c1 { color: #546E7A !important } /* Misc */
pre.light-theme .copy { background: #BBB !important } /* Misc */


.c1 { color: #EEFFFF !important } /* Misc */
.go { color: #EEFFFF !important } /* Misc */
pre.light-theme .kn { color: #2838b0 !important} /* Keyword.Namespace */
pre.light-theme .kp { color: #2838b0 !important} /* Keyword.Pseudo */
pre.light-theme .kr { color: #2838b0 !important} /* Keyword.Reserved */
pre.light-theme .kt { color: #2838b0; font-style: italic !important} /* Keyword.Type */
pre.light-theme .m { color: #444444 !important} /* Literal.Number */
pre.light-theme .s { color: #b83838 !important} /* Literal.String */
pre.light-theme .na { color: #388038 !important} /* Name.Attribute */
pre.light-theme .nb { color: #388038 !important} /* Name.Builtin */
pre.light-theme .nc { color: #287088 !important} /* Name.Class */
pre.light-theme .no { color: #b85820 !important} /* Name.Constant */
pre.light-theme .nd { color: #287088 !important} /* Name.Decorator */
pre.light-theme .ni { color: #709030 !important} /* Name.Entity */
pre.light-theme .ne { color: #908828 !important} /* Name.Exception */
pre.light-theme .nf { color: #785840 !important} /* Name.Function */
pre.light-theme .nl { color: #289870 !important} /* Name.Label */
pre.light-theme .nn { color: #289870 !important} /* Name.Namespace */
pre.light-theme .nt { color: #2838b0 !important} /* Name.Tag */
pre.light-theme .nv { color: #b04040 !important} /* Name.Variable */
pre.light-theme .ow { color: #a848a8 !important} /* Operator.Word */
pre.light-theme .pm { color: #888888 !important} /* Punctuation.Marker */
pre.light-theme .w { color: #a89028 !important} /* Text.Whitespace */
pre.light-theme .mb { color: #444444 !important} /* Literal.Number.Bin */
pre.light-theme .mf { color: #444444 !important} /* Literal.Number.Float */
pre.light-theme .mh { color: #444444 !important} /* Literal.Number.Hex */
pre.light-theme .mi { color: #444444 !important} /* Literal.Number.Integer */
pre.light-theme .mo { color: #444444 !important} /* Literal.Number.Oct */
pre.light-theme .sa { color: #444444 !important} /* Literal.String.Affix */
pre.light-theme .sb { color: #b83838 !important} /* Literal.String.Backtick */
pre.light-theme .sc { color: #a848a8 !important} /* Literal.String.Char */
pre.light-theme .dl { color: #b85820 !important} /* Literal.String.Delimiter */
pre.light-theme .sd { color: #b85820; font-style: italic !important} /* Literal.String.Doc */
pre.light-theme .s2 { color: #b83838 !important} /* Literal.String.Double */
pre.light-theme .se { color: #709030 !important} /* Literal.String.Escape */
pre.light-theme .sh { color: #b83838 !important} /* Literal.String.Heredoc */
pre.light-theme .si { color: #b83838; text-decoration: underline !important} /* Literal.String.Interpol */
pre.light-theme .sx { color: #a848a8 !important} /* Literal.String.Other */
pre.light-theme .sr { color: #a848a8 !important} /* Literal.String.Regex */
pre.light-theme .s1 { color: #b83838 !important} /* Literal.String.Single */
pre.light-theme .ss { color: #b83838 !important} /* Literal.String.Symbol */
pre.light-theme .bp { color: #388038; font-style: italic !important} /* Name.Builtin.Pseudo */
pre.light-theme .fm { color: #b85820 !important} /* Name.Function.Magic */
pre.light-theme .vc { color: #b04040 !important} /* Name.Variable.Class */
pre.light-theme .vg { color: #908828 !important} /* Name.Variable.Global */
pre.light-theme .vi { color: #b04040 !important} /* Name.Variable.Instance */
pre.light-theme .vm { color: #b85820 !important} /* Name.Variable.Magic */
pre.light-theme .il { color: #444444 !important} /* Literal.Number.Integer.Long */
pre.light-theme .n { color: #444444 !important} /* Misc */
pre.light-theme .o { color: #444 !important} /* Misc */
pre.light-theme .p { color: #444 !important} /* Misc */
pre.light-theme .k { color: #a848a8 !important} /* Misc */
pre.light-theme .kc { color: #2838b0 !important} /* Misc */
34 changes: 34 additions & 0 deletions docs/api_docs/tes.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
py-tes
===========

.. toctree::
:caption: API Docs
:name: api_docs
:hidden:
:maxdepth: 1

api_docs/tes

tes.client module
-----------------

.. automodule:: tes.client
:members:
:undoc-members:
:show-inheritance:

tes.models module
-----------------

.. automodule:: tes.models
:members:
:undoc-members:
:show-inheritance:

tes.utils module
----------------

.. automodule:: tes.utils
:members:
:undoc-members:
:show-inheritance:
8 changes: 3 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,13 @@
import sys
import os
from sphinxawesome_theme.postprocess import Icons

import tes

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath("../"))

import tes

# -- General configuration ------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
Expand Down Expand Up @@ -127,8 +125,8 @@
"logo_light": "logo-ga4gh-light.png",
"logo_dark": "logo-ga4gh-dark.png",
"main_nav_links": {
"About": "index",
"API": "api/tes",
"About": "https://github.com/ohsu-comp-bio/py-tes",
"Docs": "https://github.com/ohsu-comp-bio/py-tes",
"GitHub": "https://github.com/ohsu-comp-bio/py-tes",
},
"awesome_external_links": True,
Expand Down
165 changes: 16 additions & 149 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
py-tes
======

.. image:: https://img.shields.io/github/actions/workflow/status/ohsu-comp-bio/py-tes/tests.yml?logo=github
:alt: GitHub Actions Test Status
:target: https://github.com/ohsu-comp-bio/py-tes/actions
.. image:: https://travis-ci.org/ohsu-comp-bio/py-tes.svg?branch=master
:target: https://travis-ci.org/ohsu-comp-bio/py-tes
.. image:: https://coveralls.io/repos/github/ohsu-comp-bio/py-tes/badge.svg?branch=master
:target: https://coveralls.io/github/ohsu-comp-bio/py-tes?branch=master
:target: https://coveralls.io/github/ohsu-comp-bio/py-tes?branch=master
.. image:: https://img.shields.io/badge/License-MIT-yellow.svg
:target: https://opensource.org/licenses/MIT
:target: https://opensource.org/licenses/MIT

*py-tes* is a library for interacting with servers implementing the
`GA4GH Task Execution
Expand All @@ -30,11 +29,10 @@ Available on `PyPI <https://pypi.org/project/py-tes/>`__.
Example
~~~~~~~

.. code:: python
::

import tes

# define task
task = tes.Task(
executors=[
tes.Executor(
Expand All @@ -44,167 +42,36 @@ Example
]
)

# create client
cli = tes.HTTPClient("https://funnel.example.com", timeout=5)

# access endpoints
service_info = cli.get_service_info()
cli = tes.HTTPClient("http://funnel.example.com", timeout=5)
task_id = cli.create_task(task)
task_info = cli.get_task(task_id, view="BASIC")
res = cli.get_task(task_id)
cli.cancel_task(task_id)
tasks_list = cli.list_tasks(view="MINIMAL") # default view

How to…
~~~~~~~

Makes use of the objects above…

…export a model to a dictionary
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

task_dict = task.as_dict(drop_empty=False)

``task_dict`` contents:

.. code:: console

{'id': None, 'state': None, 'name': None, 'description': None, 'inputs': None, 'outputs': None, 'resources': None, 'executors': [{'image': 'alpine', 'command': ['echo', 'hello'], 'workdir': None, 'stdin': None, 'stdout': None, 'stderr': None, 'env': None}], 'volumes': None, 'tags': None, 'logs': None, 'creation_time': None}

…export a model to JSON
^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

task_json = task.as_json() # also accepts `drop_empty` arg

``task_json`` contents:

.. code:: console

{"executors": [{"image": "alpine", "command": ["echo", "hello"]}]}

…pretty print a model
^^^^^^^^^^^^^^^^^^^^^

.. code:: python

print(task.as_json(indent=3)) # keyword args are passed to `json.dumps()`

Output:

.. code:: json

{
"executors": [
{
"image": "alpine",
"command": [
"echo",
"hello"
]
}
]
}

…access a specific task from the task list
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

specific_task = tasks_list.tasks[5]

``specific_task`` contents:

.. code:: console

Task(id='393K43', state='COMPLETE', name=None, description=None, inputs=None, outputs=None, resources=None, executors=None, volumes=None, tags=None, logs=None, creation_time=None)

…iterate over task list items
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

for t in tasks_list[:3]:
print(t.as_json(indent=3))

Output:

.. code:: console

{
"id": "task_A2GFS4",
"state": "RUNNING"
}
{
"id": "task_O8G1PZ",
"state": "CANCELED"
}
{
"id": "task_W246I6",
"state": "COMPLETE"
}

…instantiate a model from a JSON representation
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

.. code:: python

task_from_json = tes.client.unmarshal(task_json, tes.Task)

``task_from_json`` contents:

.. code:: console

Task(id=None, state=None, name=None, description=None, inputs=None, outputs=None, resources=None, executors=[Executor(image='alpine', command=['echo', 'hello'], workdir=None, stdin=None, stdout=None, stderr=None, env=None)], volumes=None, tags=None, logs=None, creation_time=None)

Which is equivalent to ``task``:

.. code:: python

print(task_from_json == task)

Output:

.. code:: console

True

.. _main-support:

-------
Support
~~~~~~~
-------

* For releases, see :ref:`Changelog <changelog>`.
* Check :ref:`frequently asked questions (FAQ) <project_info-faq>`.
* For **bugs and feature requests**, please use the `issue tracker <https://github.com/ohsu-comp-bio/tes/issues>`_.
* For **contributions**, visit py-tes on `Github <https://github.com/ohsu-comp-bio/py-tes>`_
* For **contributions**, visit py-tes on `Github <https://github.com/ohsu-comp-bio/tes>`_ and read the :ref:`guidelines <project_info-contributing>`.

.. _main-resources:

---------
Resources
~~~~~~~~~

`cwl-tes <https://github.com/ohsu-comp-bio/cwl-tes>`_
cwl-tes submits your tasks to a TES server. Task submission is parallelized when possible.

`Funnel <https://ohsu-comp-bio.github.io/funnel/>`_
Funnel is a toolkit for distributed task execution with a simple API.

`ga4gh-tes <https://github.com/microsoft/ga4gh-tes>`_
C# implementation of the GA4GH TES API; provides distributed batch task execution on Microsoft Azure

`Nextflow <https://www.nextflow.io/>`_
Nextflow enables scalable and reproducible scientific workflows using software containers. It allows the adaptation of pipelines written in the most common scripting languages.
---------

`Snakemake <https://snakemake.github.io/>`_
The Snakemape workflow management system is a tool to create reproducible and scalable data analyses
`Snakemake Wrappers Repository <https://snakemake-wrappers.readthedocs.org>`_
The Snakemake Wrapper Repository is a collection of reusable wrappers that allow to quickly use popular tools from Snakemake rules and workflows.

.. toctree::
:caption: API
:name: api
:name: api_docs
:hidden:
:maxdepth: 1

api/tes
api_docs/tes
4 changes: 1 addition & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,4 @@ immutables
sphinxawesome-theme
snakemake-interface-common
snakemake-interface-executor-plugins
snakemake-interface-storage-plugins
attrs
python-dateutil
snakemake-interface-storage-plugins
Loading
Loading