|
| 1 | +Deprecating a version of C-PAC |
| 2 | +============================== |
| 3 | + |
| 4 | +In the rare occasion that a version of C-PAC needs to be deprecated, we add |CRITICAL_ALERT.rst| as a runtime warning and rename the deprecated image tag to ``${DEPRECATED_TAG}-DEPRECATED`` and replace the original tag for the deprecated image with an image that only displays |CRITICAL_ALERT.rst|_. For example, ``fcpindi/c-pac:release-v1.8.1-DEPRECATED`` is the tag that would be needed to run v1.8.1 after v1.8.1 was deprecated. |
| 5 | + |
| 6 | +To semiautomatically deprecate a published version of C-PAC, follow these steps: |
| 7 | + |
| 8 | +#. Write a ``CRITICAL ALERT`` (e.g., |CRITICAL ALERT 1.8.4|_) describing the need for the deprecation, the affected versions, and any recommendations. |
| 9 | +#. Include that ``CRITICAL ALERT`` in the GitHub release notes for new version (e.g., |1.8.4 release notes|_). |
| 10 | +#. Use |CPAC-Development/deprecate|_ to deprecate the affected version images on Docker Hub. This process requires adequate permissions in the `fcp-indi organization on Docker Hub <https://hub.docker.com/orgs/fcpindi>`_ to ``docker push``. |
| 11 | + |
| 12 | + #. If you aren't already logged into Docker Hub, ``docker login``. |
| 13 | + |
| 14 | + In a local clone or copy of |CPAC-Development|_: |
| 15 | + |
| 16 | + #. Replace the critical alert in |CRITICAL_ALERT.rst|_ with the ``CRITICAL_ALERT`` from step one, above. |
| 17 | + #. Update |cpac_pipeline.py|_ and |run.py|_: |
| 18 | + |
| 19 | + #. Overwrite the current versions in the |CPAC-Development/deprecate|_ with the versions from the source code of the version of C-PAC to deprecate. |
| 20 | + #. Add |
| 21 | + |
| 22 | + .. code:: Python |
| 23 | +
|
| 24 | + shutil.copyfile('/CRITICAL_ALERT.rst', |
| 25 | + os.path.join(log_dir, 'CRITICAL_ALERT.rst')) |
| 26 | +
|
| 27 | + to |cpac_pipeline.py|_ after |
| 28 | + |
| 29 | + .. code:: Python |
| 30 | +
|
| 31 | + if not os.path.exists(log_dir): |
| 32 | + os.makedirs(os.path.join(log_dir)) |
| 33 | +
|
| 34 | + (e.g., |cpac_pipeline.py example 1|_) and make sure ``shutil`` is imported before calling that library. |
| 35 | + |
| 36 | + #. Also in |cpac_pipeline.py|_, update the variable ``execution_info`` to include ``{critical_alert}`` at the end, like |cpac_pipeline.py example 2|_: |
| 37 | + |
| 38 | + .. code:: Python |
| 39 | +
|
| 40 | + execution_info = """ |
| 41 | +
|
| 42 | + End of subject workflow {workflow} |
| 43 | +
|
| 44 | + CPAC run complete: |
| 45 | +
|
| 46 | + Pipeline configuration: {pipeline} |
| 47 | + Subject workflow: {workflow} |
| 48 | + Elapsed run time (minutes): {elapsed} |
| 49 | + Timing information saved in {log_dir}/cpac_individual_timing_{pipeline}.csv |
| 50 | + System time of start: {run_start} |
| 51 | + System time of completion: {run_finish} |
| 52 | +
|
| 53 | + {critical_alert} |
| 54 | + """ |
| 55 | +
|
| 56 | + .. note:: |
| 57 | + |
| 58 | + There are probably at least two definitions of ``execution_info`` that need ``{critical_alert}`` appended to them (e.g., |cpac_pipeline.py example 3|_). |
| 59 | + |
| 60 | + #. Also in |cpac_pipeline.py|_, define ``critical_alert`` based on the |CRITICAL_ALERT.rst|_ file you already updated (e.g., |cpac_pipeline.py example 4|_): |
| 61 | + |
| 62 | + .. code:: Python |
| 63 | +
|
| 64 | + with open('/CRITICAL_ALERT.rst', 'r') as critical_alert_file: |
| 65 | + critical_alert = '\n'.join([ |
| 66 | + f' {line.rstrip()}' for line in critical_alert_file.readlines()]) |
| 67 | +
|
| 68 | + #. Also in |cpac_pipeline.py|_, update any calls to ``execution_info.format()`` to populate the string variable ``{critical_alert}`` with the ``critical_alert`` you defined above (e.g., |cpac_pipeline.py example 5|_): |
| 69 | + |
| 70 | + .. code:: Python |
| 71 | +
|
| 72 | + logger.info(execution_info.format( |
| 73 | + workflow=workflow.name, |
| 74 | + pipeline=c.pipeline_setup['pipeline_name'], |
| 75 | + log_dir=c.pipeline_setup['log_directory']['path'], |
| 76 | + elapsed=(time.time() - pipeline_start_time) / 60, |
| 77 | + run_start=pipeline_start_datetime, |
| 78 | + run_finish=strftime("%Y-%m-%d %H:%M:%S"), |
| 79 | + critical_alert=critical_alert |
| 80 | + )) |
| 81 | +
|
| 82 | + #. In |run.py|_, print the contents of |CRITICAL_ALERT.rst|_, e.g. |run.py example 1|_: |
| 83 | + |
| 84 | + .. code:: Python |
| 85 | +
|
| 86 | + with open('/CRITICAL_ALERT.rst', 'r') as critical_alert_file: |
| 87 | + critical_alert = ''.join([line for line in |
| 88 | + critical_alert_file.readlines() if |
| 89 | + not line.startswith('.. ')]) |
| 90 | + print(critical_alert) |
| 91 | +
|
| 92 | + #. From the ``deprecate`` subdirectory, run |
| 93 | + |
| 94 | + .. code:: BASH |
| 95 | +
|
| 96 | + ./build_and_deprecate ${DEPRECATED_TAG} ${RECOMMENDED_MINIMUM_VERSION} |
| 97 | +
|
| 98 | + for each tag (as ``${DEPRECATED_TAG}``) that needs to be deprecated. This script will build the replacement images and push them to Docker Hub, overwriting the original image. See |Docker Hub tags|_ for all C-PAC tags currently published on Docker Hub. ``${RECOMMENDED_MINIMUM_VERSION}`` is the |semver| without any leading ``v``. For example |
| 99 | + |
| 100 | + .. code:: BASH |
| 101 | +
|
| 102 | + for each TAG in "" -lite -ABCD-HCP -fMRIPrep-LTS |
| 103 | + do |
| 104 | + ./build_and_deprecate release-v1.8.1$TAG 1.8.4 |
| 105 | + done |
| 106 | +
|
| 107 | + to deprecate all variants of C-PAC v1.8.1 with recommended mimumum version v1.8.4. |
| 108 | + |
| 109 | + If the version to be deprecated is already deprecated but the critical alert needs to be updated, that can be done with the same syntax with ``./rebuild_and_deprecate`` (e.g., |
| 110 | + |
| 111 | + .. code:: BASH |
| 112 | +
|
| 113 | + ./rebuild_and_deprecate release-v1.8.1-lite 1.8.4 |
| 114 | +
|
| 115 | + to update the critical alert for ``release-v1.8.1-lite`` and ``release-v1.8.1-DEPRECATED``). |
| 116 | + |
| 117 | +#. Add the critical alert to the release notes of each newly deprecated version, or update the critical alert if one already exists for that version (e.g., |1.8.1 release notes|_). |
| 118 | +#. Trigger a rebuild of this documentation for the new version of C-PAC. |
| 119 | + |
| 120 | +.. |1.8.1 release notes| replace:: ``C-PAC/releases/v.1.8.1`` "C-PAC Version 1.8.1 Beta" |
| 121 | + |
| 122 | +.. _1.8.1 release notes: https://github.com/FCP-INDI/C-PAC/releases/tag/v1.8.1 |
| 123 | + |
| 124 | +.. |1.8.4 release notes| replace:: ``C-PAC/releases/v.1.8.4`` "C-PAC Version 1.8.4 Beta" |
| 125 | + |
| 126 | +.. _1.8.4 release notes: https://github.com/FCP-INDI/C-PAC/releases/tag/v1.8.4 |
| 127 | + |
| 128 | +.. |CRITICAL ALERT 1.8.4| replace:: "Critical Alert for fMRIPrep-Options in C-PAC v1.8.1 - v1.8.3" |
| 129 | + |
| 130 | +.. _CRITICAL ALERT 1.8.4: https://github.com/FCP-INDI/CPAC-Development/blob/028e792/deprecate/CRITICAL_ALERT.rst#critical-alert-for-fmriprep-options-in-c-pac-v181---v183 |
| 131 | + |
| 132 | +.. |CRITICAL_ALERT.rst| replace:: ``CRITICAL_ALERT.rst`` |
| 133 | + |
| 134 | +.. _CRITICAL_ALERT.rst: https://github.com/FCP-INDI/CPAC-Development/blob/main/deprecate/CRITICAL_ALERT.rst |
| 135 | + |
| 136 | +.. |CPAC-Development| replace:: ``CPAC-Development`` |
| 137 | + |
| 138 | +.. _CPAC-Development: https://github.com/FCP-INDI/CPAC-Development |
| 139 | + |
| 140 | +.. |CPAC-Development/deprecate| replace:: ``CPAC-Development/deprecate`` |
| 141 | + |
| 142 | +.. _CPAC-Development/deprecate: https://github.com/FCP-INDI/CPAC-Development/tree/028e7929188df99241e8eea78d20d0fd27dbe509/deprecate |
| 143 | + |
| 144 | +.. |cpac_pipeline.py| replace:: ``cpac_pipeline.py`` |
| 145 | + |
| 146 | +.. _cpac_pipeline.py: https://github.com/FCP-INDI/CPAC-Development/blob/DEPRECATE/deprecate/cpac_pipeline.py |
| 147 | + |
| 148 | +.. |cpac_pipeline.py example 1| replace:: ``cpac_pipeline.py#L264-L265@6cd6c67`` |
| 149 | + |
| 150 | +.. _cpac_pipeline.py example 1: https://github.com/FCP-INDI/CPAC-Development/blob/6cd6c67/deprecate/cpac_pipeline.py#L264-L265 |
| 151 | + |
| 152 | +.. |cpac_pipeline.py example 2| replace:: ``cpac_pipeline.py#L370@6cd6c67`` |
| 153 | + |
| 154 | +.. _cpac_pipeline.py example 2: https://github.com/FCP-INDI/CPAC-Development/blob/6cd6c67/deprecate/cpac_pipeline.py#L370 |
| 155 | + |
| 156 | +.. |cpac_pipeline.py example 3| replace:: ``cpac_pipeline.py#L706@6cd6c67`` |
| 157 | + |
| 158 | +.. _cpac_pipeline.py example 3: https://github.com/FCP-INDI/CPAC-Development/blob/6cd6c67/deprecate/cpac_pipeline.py#L706 |
| 159 | + |
| 160 | +.. |cpac_pipeline.py example 4| replace:: ``cpac_pipeline.py#L373-L376@6cd6c67`` |
| 161 | + |
| 162 | +.. _cpac_pipeline.py example 4: https://github.com/FCP-INDI/CPAC-Development/blob/6cd6c67/deprecate/cpac_pipeline.py#L373-L376 |
| 163 | + |
| 164 | +.. |cpac_pipeline.py example 5| replace:: ``cpac_pipeline.py#L723@6cd6c67`` |
| 165 | + |
| 166 | +.. _cpac_pipeline.py example 5: https://github.com/FCP-INDI/CPAC-Development/blob/6cd6c67/deprecate/cpac_pipeline.py#L723 |
| 167 | + |
| 168 | +.. |Docker Hub tags| replace:: fcpindi/c-pac Tags | Docker Hub |
| 169 | + |
| 170 | +.. _Docker Hub tags: https://hub.docker.com/repository/docker/fcpindi/c-pac/tags |
| 171 | + |
| 172 | +.. |run.py| replace:: ``run.py`` |
| 173 | + |
| 174 | +.. _run.py: https://github.com/FCP-INDI/CPAC-Development/blob/DEPRECATE/deprecate/run.py |
| 175 | + |
| 176 | +.. |run.py example 1| replace:: ``run.py#L216-L220@6cd6c67`` |
| 177 | + |
| 178 | +.. _run.py example 1: https://github.com/FCP-INDI/CPAC-Development/blob/6cd6c67/deprecate/run.py#L216-L220 |
| 179 | + |
| 180 | +.. |semver| raw:: HTML |
| 181 | + |
| 182 | + <span title="semantic version">semver</span> |
0 commit comments