Skip to content

Commit

Permalink
Merge pull request #66 from pepkit/dev
Browse files Browse the repository at this point in the history
v0.5.0 Release
  • Loading branch information
donaldcampbelljr authored Aug 8, 2023
2 parents 3222fc4 + cb5f3d9 commit 9fc39b4
Show file tree
Hide file tree
Showing 39 changed files with 2,331 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/run-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Run pytests

on:
push:
branches: [master]
branches: [master, dev]
pull_request:
branches: [master]
branches: [master, dev]
workflow_dispatch:
inputs: null

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,4 @@ dmypy.json

# Pyre type checker
.pyre/
/tests/data/reports/
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ include requirements/*
include README.md
include pipestat/schemas/*
include pipestat/backends/*
include pipestat/jinja_templates/*
4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ coverage:
target: 80% # the required coverage value
threshold: 1% # the leniency in hitting the target
informational: true
patch:
default:
target: 80%
informational: true
ignore:
- "*/argparser.py"
- "*/cli.py"
Expand Down
10 changes: 8 additions & 2 deletions docs/api_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Pipestat standardizes reporting of pipeline results and pipeline status manageme


```python
def __init__(self, sample_name: Optional[str]=None, schema_path: Optional[str]=None, results_file_path: Optional[str]=None, database_only: Optional[bool]=True, config_file: Optional[str]=None, config_dict: Optional[dict]=None, flag_file_dir: Optional[str]=None, show_db_logs: bool=False, pipeline_type: Optional[str]=None, pipeline_name: Optional[str]='default_pipeline_name', result_formatter: staticmethod=<function default_formatter at 0x7f70b1358c10>, multi_pipelines: bool=False)
def __init__(self, sample_name: Optional[str]=None, schema_path: Optional[str]=None, results_file_path: Optional[str]=None, database_only: Optional[bool]=True, config_file: Optional[str]=None, config_dict: Optional[dict]=None, flag_file_dir: Optional[str]=None, show_db_logs: bool=False, pipeline_type: Optional[str]=None, pipeline_name: Optional[str]='default_pipeline_name', result_formatter: staticmethod=<function default_formatter at 0x7f048f1a8d30>, multi_pipelines: bool=False)
```

Initialize the PipestatManager object
Expand Down Expand Up @@ -292,6 +292,12 @@ Status schema source



```python
def summarize(self, *args, **kwargs)
```



```python
def validate_schema(self) -> None
```
Expand All @@ -307,4 +313,4 @@ Check schema for any possible issues



*Version Information: `pipestat` v0.4.0, generated by `lucidoc` v0.4.4*
*Version Information: `pipestat` v0.5.0, generated by `lucidoc` v0.4.4*
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format.

## [0.5.0] - 2023-08-08
### Added

- Add summarize function to generate static html results report.

## [0.4.1] - 2023-07-26

Expand Down
49 changes: 26 additions & 23 deletions docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ Pipestat offers a CLI that can be access via the `pipestat` command in the shell
Here you can see the command-line usage instructions for the main command and for each subcommand:
## `pipestat --help`
```console
version: 0.4.0
usage: pipestat [-h] [--version] [--silent] [--verbosity V] [--logdev] {report,inspect,remove,retrieve,status,init} ...
version: 0.5.0
usage: pipestat [-h] [--version] [--silent] [--verbosity V] [--logdev]
{report,inspect,remove,retrieve,status,init,summarize} ...

pipestat - report pipeline results

positional arguments:
{report,inspect,remove,retrieve,status,init}
{report,inspect,remove,retrieve,status,init,summarize}
report Report a result.
inspect Inspect a database.
remove Remove a result.
retrieve Retrieve a result.
status Manage pipeline status.
init Initialize generic config file
summarize Generates HTML Report

options:
-h, --help show this help message and exit
Expand All @@ -26,10 +28,12 @@ options:
--verbosity V Set logging level (1-5 or logging module level name)
--logdev Expand content of logging message format.

Pipestat standardizes reporting of pipeline results and pipeline status management. It formalizes a way for pipeline
developers and downstream tools developers to communicate -- results produced by a pipeline can easily and
reliably become an input for downstream analyses. A PipestatManager object exposes an API for interacting with the
results and pipeline status and can be backed by either a YAML-formatted file or a database.
Pipestat standardizes reporting of pipeline results and pipeline status
management. It formalizes a way for pipeline developers and downstream tools
developers to communicate -- results produced by a pipeline can easily and
reliably become an input for downstream analyses. A PipestatManager object
exposes an API for interacting with the results and pipeline status and can be
backed by either a YAML-formatted file or a database.
```

## `pipestat report --help`
Expand All @@ -55,8 +59,8 @@ options:
reported. If not provided 'PIPESTAT_RESULTS_SCHEMA' env var
will be used. Currently not set
--status-schema ST Path to the status schema. Default will be used if not
provided: /usr/local/lib/python3.10/site-
packages/pipestat/schemas/status_schema.yaml
provided: /home/drc/GITHUB/pipestat/pipestat/venv/lib/pytho
n3.10/site-packages/pipestat/schemas/status_schema.yaml
--flag-dir FD Path to the flag directory in case YAML file is the
pipestat backend.
-i I, --result-identifier I ID of the result to report; needs to be defined in the
Expand All @@ -69,7 +73,6 @@ options:
name clashes
-t, --skip-convert Whether skip result type conversion into the required class
in case it does not meet the schema requirements

```

## `pipestat inspect --help`
Expand All @@ -79,9 +82,9 @@ usage: pipestat inspect [-h] [-n N] [-f F] [-c C] [-a] [-s S] [--status-schema S

Inspect a database.

optional arguments:
options:
-h, --help show this help message and exit
-n N, --project-name N Name of the pipeline to report result for. If not provided
-n N, --project-name N Name of the pipeline to report result for. If not provided
'PIPESTAT_PROJECT_NAME' env var will be used. Currently not set
-f F, --results-file F Path to the YAML file where the results will be stored. This
file will be used as pipestat backend and to restore the
Expand All @@ -94,7 +97,7 @@ optional arguments:
reported. If not provided 'PIPESTAT_RESULTS_SCHEMA' env var will
be used. Currently not set
--status-schema ST Path to the status schema. Default will be used if not provided:
/usr/local/lib/python3.9/site-
/home/drc/GITHUB/pipestat/pipestat/venv/lib/python3.10/site-
packages/pipestat/schemas/status_schema.yaml
--flag-dir FD Path to the flag directory in case YAML file is the pipestat
backend.
Expand Down Expand Up @@ -124,16 +127,15 @@ options:
reported. If not provided 'PIPESTAT_RESULTS_SCHEMA' env var
will be used. Currently not set
--status-schema ST Path to the status schema. Default will be used if not
provided: /usr/local/lib/python3.10/site-
packages/pipestat/schemas/status_schema.yaml
provided: /home/drc/GITHUB/pipestat/pipestat/venv/lib/pytho
n3.10/site-packages/pipestat/schemas/status_schema.yaml
--flag-dir FD Path to the flag directory in case YAML file is the
pipestat backend.
-i I, --result-identifier I ID of the result to report; needs to be defined in the
schema
-r R, --sample-name R ID of the record to report the result for. If not provided
'PIPESTAT_SAMPLE_NAME' env var will be used. Currently not
set

```

## `pipestat retrieve --help`
Expand All @@ -159,16 +161,15 @@ options:
reported. If not provided 'PIPESTAT_RESULTS_SCHEMA' env var
will be used. Currently not set
--status-schema ST Path to the status schema. Default will be used if not
provided: /usr/local/lib/python3.10/site-
packages/pipestat/schemas/status_schema.yaml
provided: /home/drc/GITHUB/pipestat/pipestat/venv/lib/pytho
n3.10/site-packages/pipestat/schemas/status_schema.yaml
--flag-dir FD Path to the flag directory in case YAML file is the
pipestat backend.
-i I, --result-identifier I ID of the result to report; needs to be defined in the
schema
-r R, --sample-name R ID of the record to report the result for. If not provided
'PIPESTAT_SAMPLE_NAME' env var will be used. Currently not
set

```

## `pipestat status --help`
Expand All @@ -182,7 +183,7 @@ positional arguments:
set Set status.
get Get status.

optional arguments:
options:
-h, --help show this help message and exit
```

Expand All @@ -208,8 +209,8 @@ options:
reported. If not provided 'PIPESTAT_RESULTS_SCHEMA' env var will
be used. Currently not set
--status-schema ST Path to the status schema. Default will be used if not provided:
/usr/local/lib/python3.10
/site-packages/pipestat/schemas/status_schema.yaml
/home/drc/GITHUB/pipestat/pipestat/venv/lib/python3.10/site-
packages/pipestat/schemas/status_schema.yaml
--flag-dir FD Path to the flag directory in case YAML file is the pipestat
backend.
-r R, --sample-name R ID of the record to report the result for. If not provided
Expand Down Expand Up @@ -242,9 +243,11 @@ options:
reported. If not provided 'PIPESTAT_RESULTS_SCHEMA' env var will
be used. Currently not set
--status-schema ST Path to the status schema. Default will be used if not provided:
/usr/local/lib/python3.10/site-packages/pipestat/schemas/status_schema.yaml
/home/drc/GITHUB/pipestat/pipestat/venv/lib/python3.10/site-
packages/pipestat/schemas/status_schema.yaml
--flag-dir FD Path to the flag directory in case YAML file is the pipestat
backend.
-r R, --sample-name R ID of the record to report the result for. If not provided
'PIPESTAT_SAMPLE_NAME' env var will be used. Currently not set
```

9 changes: 9 additions & 0 deletions docs_jupyter/cli.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,15 @@
"cat /usr/local/lib/python3.9/site-packages/pipestat/schemas/status_schema.yaml"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## HTML Report Generation\n",
"\n",
"To generate a static html report, call `pipestat summarize --results-file PIPESTAT_RESULTS_FILE --schema PIPESTAT_RESULTS_SCHEMA`"
]
},
{
"cell_type": "code",
"execution_count": 51,
Expand Down
13 changes: 12 additions & 1 deletion docs_jupyter/python_api.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1128,12 +1128,23 @@
"psm_no_schema.get_status(sample_name=\"sample1\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Generate static HTML Report using the `summarize` command\n",
"\n",
"You can generate a static browsable html report using the `summarize` function:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
"source": [
"psm.summarize()"
]
}
],
"metadata": {
Expand Down
2 changes: 1 addition & 1 deletion pipestat/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.4.1"
__version__ = "0.5.0"
28 changes: 28 additions & 0 deletions pipestat/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
RETRIEVE_CMD = "retrieve"
STATUS_CMD = "status"
INIT_CMD = "init"
SUMMARIZE_CMD = "summarize"
SUBPARSER_MESSAGES = {
REPORT_CMD: "Report a result.",
INSPECT_CMD: "Inspect a database.",
REMOVE_CMD: "Remove a result.",
RETRIEVE_CMD: "Retrieve a result.",
STATUS_CMD: "Manage pipeline status.",
INIT_CMD: "Initialize generic config file",
SUMMARIZE_CMD: "Generates HTML Report",
}

STATUS_GET_CMD = "get"
Expand Down Expand Up @@ -255,4 +257,30 @@ def add_subparser(
"-d", "--data", action="store_true", help="Whether to display the data"
)

# Summarize
for cmd in [SUMMARIZE_CMD]:
sps[cmd].add_argument(
"-f",
"--results-file",
type=str,
metavar="F",
help=f"Path to the YAML file where the results will be stored. "
f"This file will be used as {PKG_NAME} backend and to restore"
f" the reported results across sessions",
)
sps[cmd].add_argument(
"-c",
"--config",
type=str,
metavar="C",
help=f"Path to the YAML configuration file. {_env_txt('config')}",
)
sps[cmd].add_argument(
"-s",
"--schema",
type=str,
metavar="S",
help=f"Path to the schema that defines the results that can be reported. {_env_txt('schema')}",
)

return parser
11 changes: 11 additions & 0 deletions pipestat/backends/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def count_records(
_LOGGER.warning("Not implemented yet for this backend")
pass

def get_samples(
self,
pipeline_type: Optional[str] = None,
):
_LOGGER.warning("Not implemented yet for this backend")
pass

def get_status(self, sample_name: str, pipeline_type: Optional[str] = None) -> Optional[str]:
_LOGGER.warning("Not implemented yet for this backend")

Expand Down Expand Up @@ -137,3 +144,7 @@ def remove_record(
pipeline_type: Optional[str] = None,
) -> bool:
_LOGGER.warning("Not implemented yet for this backend")

def summarize(self) -> None:
_LOGGER.warning("Not implemented yet for this backend")
pass
36 changes: 36 additions & 0 deletions pipestat/backends/dbbackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,42 @@ def get_one_record(self, table_name: str, rid: Optional[str] = None):
if record:
return record

def get_samples(
self,
pipeline_type: Optional[str] = None,
) -> Optional[list]:
"""Returns list of sample names and pipeline type as a list of tuples that have been reported, regardless of sample or project level"""
all_samples_list = []

if pipeline_type is not None:
table_name = self.get_table_name(pipeline_type)
mod = self.get_model(table_name=table_name, strict=True)
with self.session as s:
sample_list = []
stmt = sql_select(mod)
records = s.exec(stmt).all()
for i in records:
pair = (i.sample_name, pipeline_type)
sample_list.append(pair)

return sample_list
else:
pipelines = ["sample", "project"]
for i in pipelines:
pipeline_type = i
table_name = self.get_table_name(pipeline_type)
mod = self.get_model(table_name=table_name, strict=True)
with self.session as s:
sample_list = []
stmt = sql_select(mod)
records = s.exec(stmt).all()
for i in records:
pair = (i.sample_name, pipeline_type)
sample_list.append(pair)

all_samples_list += sample_list
return all_samples_list

def get_status(self, sample_name: str, pipeline_type: Optional[str] = None) -> Optional[str]:
"""
Get pipeline status
Expand Down
Loading

0 comments on commit 9fc39b4

Please sign in to comment.