Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

ENH: Switch recommonmark to MyST-parser #787

Merged
merged 25 commits into from
Aug 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
267d4e8
📝 Create basic for ML API
peterhessey Aug 5, 2022
806f261
📝 Add ML/configs base doc files
peterhessey Aug 5, 2022
0cbd7c7
📝 Finish ML/configs API
peterhessey Aug 8, 2022
f5c82cf
📝 Update augmentations
peterhessey Aug 8, 2022
ac0171a
📝 Add ML/dataset API docs
peterhessey Aug 8, 2022
e9fff6a
📝 Add rst skeleton for ML/models
peterhessey Aug 8, 2022
4fd8de4
📝 Fix docstring missing newlines
peterhessey Aug 8, 2022
6371548
Remove script
peterhessey Aug 8, 2022
27e7784
📝 Finish ML/models API docs
peterhessey Aug 8, 2022
6a1273f
📝 Start ML/SSL API. Fix some formatting issues
peterhessey Aug 9, 2022
562173b
📝 Correct whitespace issues in `:param`
peterhessey Aug 9, 2022
416e907
📝 Fix whitespace errors on `:return` statements
peterhessey Aug 9, 2022
a778dac
📝 Fix :return: statements
peterhessey Aug 9, 2022
33b557c
📝 Finish ML/SSL API
peterhessey Aug 9, 2022
7d4f466
📝 Add ML/utils API docs
peterhessey Aug 9, 2022
19ab5b2
📝 Add visualizer docs, fix `:raise` indents
peterhessey Aug 9, 2022
67169af
📝 Fix more issues with the `:raises:` formatting
peterhessey Aug 9, 2022
7619004
♻️ Restructuring folders
peterhessey Aug 9, 2022
bdc2a51
📝 Limit API `toctree` depth
peterhessey Aug 9, 2022
56c3a52
📝 Add primary InnerEye/ML files API to docs
peterhessey Aug 9, 2022
e9e5ee8
📝 Fix and add `InnerEye/ML/*.py` docs
peterhessey Aug 9, 2022
c1d84a8
⚰️ Remove weird `settings.json` change
peterhessey Aug 9, 2022
933bc7b
📌 Switch recommonmark to MyST-parser
peterhessey Aug 15, 2022
6e610b0
📌 Add myst-parser to `environment.yml`, lock env
peterhessey Aug 16, 2022
a9a5278
Fix conflicts merging main
peterhessey Aug 17, 2022
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
Prev Previous commit
Next Next commit
📝 Fix and add InnerEye/ML/*.py docs
  • Loading branch information
peterhessey committed Aug 9, 2022
commit e9e5ee897c034e2648b395499a400bb5ed223a1c
23 changes: 13 additions & 10 deletions InnerEye/Common/common_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,19 @@ def check_properties_are_not_none(obj: Any, ignore: Optional[List[str]] = None)

def initialize_instance_variables(func: Callable) -> Callable:
"""
Automatically assigns the input parameters.

>>> class process:
... @initialize_instance_variables
... def __init__(self, cmd, reachable=False, user='root'):
... pass
>>> p = process('halt', True)
>>> # noinspection PyUnresolvedReferences
>>> p.cmd, p.reachable, p.user
('halt', True, 'root')
Automatically assigns the input parameters. Example usage::

class process:
@initialize_instance_variables
def __init__(self, cmd, reachable=False, user='root'):
pass
p = process('halt', True)
print(p.cmd, p.reachable, p.user)

Outputs::

('halt', True, 'root')

"""
names, varargs, keywords, defaults, _, _, _ = inspect.getfullargspec(func)

Expand Down
4 changes: 1 addition & 3 deletions InnerEye/ML/deep_learning_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,10 @@ def create(project_root: Path,

:param project_root: The root folder that contains the code that submitted the present training run.
When running inside the InnerEye repository, it is the git repo root. When consuming InnerEye as a package,
this should be the root of the source code that calls the package.

this should be the root of the source code that calls the package.
:param is_offline_run: If true, this is a run outside AzureML. If False, it is inside AzureML.
:param model_name: The name of the model that is trained. This is used to generate a run-specific output
folder.

:param output_to: If provided, the output folders will be created as a subfolder of this argument. If not
given, the output folders will be created inside of the project root.
"""
Expand Down
22 changes: 12 additions & 10 deletions InnerEye/ML/lightning_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,18 @@ class InnerEyeInference(abc.ABC):
form of inference is slightly different from what PyTorch Lightning does in its `Trainer.test` method. In
particular, this inference can be executed on any of the training, validation, or test set.

The inference code calls the methods in this order:

model.on_inference_start()
for dataset_split in [Train, Val, Test]
model.on_inference_epoch_start(dataset_split, is_ensemble_model=False)
for batch_idx, item in enumerate(dataloader[dataset_split])):
model_outputs = model.forward(item)
model.inference_step(item, batch_idx, model_outputs)
model.on_inference_epoch_end()
model.on_inference_end()
The inference code calls the methods in this order::

model.on_inference_start()

for dataset_split in [Train, Val, Test]
model.on_inference_epoch_start(dataset_split, is_ensemble_model=False)
for batch_idx, item in enumerate(dataloader[dataset_split])):
model_outputs = model.forward(item)
model.inference_step(item, batch_idx, model_outputs)
model.on_inference_epoch_end()
model.on_inference_end()

"""

def on_inference_start(self) -> None:
Expand Down
5 changes: 3 additions & 2 deletions InnerEye/ML/metrics_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,9 @@ def load_execution_mode_metrics_from_df(df: pd.DataFrame,
"""
Helper function to create BinaryClassificationMetricsDict grouped by ModelExecutionMode and epoch
from a given dataframe. The following columns must exist in the provided data frame:
>>> LoggingColumns.DataSplit
>>> LoggingColumns.Epoch

* LoggingColumns.DataSplit
* LoggingColumns.Epoch

:param df: DataFrame to use for creating the metrics dict.
:param is_classification_metrics: If the current metrics are for classification or not.
Expand Down
2 changes: 1 addition & 1 deletion InnerEye/ML/model_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def model_train(checkpoint_path: Optional[Path],
def aggregate_and_create_subject_metrics_file(outputs_folder: Path) -> None:
"""
This functions takes all the subject metrics file written by each GPU (one file per GPU) and aggregates them into
one single metrics file. Results is saved in config.outputs_folder / mode.value / SUBJECT_METRICS_FILE_NAME.
one single metrics file. Results is saved in ``config.outputs_folder / mode.value / SUBJECT_METRICS_FILE_NAME``.
This is done for the metrics files for training and for validation data separately.

:param config: model config
Expand Down
13 changes: 8 additions & 5 deletions InnerEye/ML/normalize_and_visualize_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ def create_parser(yaml_file_path: Path) -> ParserResult:
Create a parser for all runner arguments, even though we are only using a subset of the arguments.
This way, we can get secrets handling in a consistent way.
In particular, this will create arguments for
--local_dataset
--azure_dataset_id

* ``--local_dataset``
* ``--azure_dataset_id``
"""
parser = create_runner_parser(SegmentationModelBase)
NormalizeAndVisualizeConfig.add_args(parser)
Expand All @@ -67,9 +68,11 @@ def get_configs(default_model_config: SegmentationModelBase,
def main(yaml_file_path: Path) -> None:
"""
Invoke either by
* specifying a model, '--model Lung'
* or specifying dataset and normalization parameters separately: --azure_dataset_id=foo --norm_method=None
In addition, the arguments '--image_channel' and '--gt_channel' must be specified (see below).

* specifying a model, ``--model Lung``
* or specifying dataset and normalization parameters separately: ``--azure_dataset_id=foo --norm_method=None``

In addition, the arguments ``--image_channel`` and ``--gt_channel`` must be specified.
"""
config, runner_config, args = get_configs(SegmentationModelBase(should_validate=False), yaml_file_path)
dataset_config = DatasetConfig(name=config.azure_dataset_id,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/rst/api/ML/core.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
InnerEye/ML Core
ML Core
================

.. toctree::
Expand Down
1 change: 1 addition & 0 deletions docs/source/rst/api/ML/core/lightning.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Lightning Components
================================

.. automodule:: InnerEye.ML.lightning_base
:exclude-members: configure_optimizers

.. automodule:: InnerEye.ML.lightning_container

Expand Down