### Start API server on Mac/Linux Source: https://growth.rcpch.ac.uk/developer/api-python Starts the API server using the 'uvicorn-start' script on macOS or Linux systems. ```bash s/uvicorn-start ``` -------------------------------- ### Start API server on Windows Source: https://growth.rcpch.ac.uk/developer/api-python Starts the API server using uvicorn with hot-reloading enabled on Windows systems. ```bash uvicorn main:app --reload ``` -------------------------------- ### Start the Zensical development server with Docker Compose Source: https://growth.rcpch.ac.uk/developer/writing-documentation Use Docker Compose to run the Zensical site in a container, allowing local preview without installing Python or Zensical. Ensure Docker and Docker Compose are installed and running. ```bash docker compose up ``` -------------------------------- ### Start Development Server without Docker Source: https://growth.rcpch.ac.uk/developer/react-client Run the React client development server directly from the command line without using Docker. This requires Node.js and npm to be installed. ```bash npm run dev ``` -------------------------------- ### Install common requirements on Windows Source: https://growth.rcpch.ac.uk/developer/api-python Installs dependencies from the common-requirements.txt file using pip within the activated virtual environment. ```bash pip install -r requirements/common-requirements.txt ``` -------------------------------- ### Install RCPCHgrowth Directly Source: https://growth.rcpch.ac.uk/researchers/introduction Install the core RCPCHgrowth package without additional notebook dependencies. Use this if you already have the necessary notebook tools installed. ```bash pip install rcpchgrowth ``` -------------------------------- ### Install React Chart Component Source: https://growth.rcpch.ac.uk/developer/react-component Install the RCPCH Digital Growth Charts React Component Library using npm. ```bash npm i --save @rcpch/digital-growth-charts-react-component-library ``` -------------------------------- ### Verify CLI Installation Source: https://growth.rcpch.ac.uk/products/command-line-client%28deprecated%29 Check if the rcpchgrowth-cli was installed correctly by running the help command. This should display available options and usage instructions. ```bash rcpchgrowth --help ``` -------------------------------- ### Install dependencies with pip Source: https://growth.rcpch.ac.uk/developer/api-python Installs project dependencies listed in requirements.txt using pip within the activated virtual environment. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install RCPCHGrowth CLI Tool Source: https://growth.rcpch.ac.uk/products/command-line-client%28deprecated%29 Install the command-line interface tool using pip. This command ensures you have the necessary package for terminal-based growth calculations. ```bash pip install rcpchgrowth-python-cli ``` -------------------------------- ### Uvicorn development server output Source: https://growth.rcpch.ac.uk/developer/api-python Example output messages from the uvicorn development server indicating it is running, reloading, and the application has started. ```text INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit) INFO: Started reloader process [61645] using watchgod INFO: Started server process [61647] INFO: Waiting for application startup. INFO: Application startup complete. ``` -------------------------------- ### Example MkDocs Navigation Configuration Source: https://growth.rcpch.ac.uk/developer/writing-documentation This excerpt from 'mkdocs.yml' demonstrates how to define the site's navigation structure, including top-level headings and nested sub-pages. ```yaml nav: - Home: "index.md" - About: - "about/about.md" - "about/overview.md" ``` -------------------------------- ### Start Docker Container Source: https://growth.rcpch.ac.uk/developer/react-client Start the Docker container for the React client. This command launches the application within the Docker environment. ```bash s/docker-start ``` -------------------------------- ### Start Docker Container for RCPCHgrowth Source: https://growth.rcpch.ac.uk/researchers/introduction Initiate the Docker container to set up the RCPCHgrowth development environment. This command builds the package and makes Jupyter notebooks accessible via a provided link. ```bash s/up ``` -------------------------------- ### Local Development Setup for Charts Package Source: https://growth.rcpch.ac.uk/developer/react-component Steps to link the local chart library with a React client for development. Ensure consistent Node.js versions and manage potential dependency conflicts. ```bash npm link npm link @rcpch/digital-growth-charts-react-component-library npm run build ``` -------------------------------- ### Upgrade pip and install virtualenv Source: https://growth.rcpch.ac.uk/developer/api-python Upgrades the pip package installer to the latest version and then installs the virtualenv package. ```bash python.exe -m pip install --upgrade pip pip install virtualenv ``` -------------------------------- ### Install RCPCHGrowth Package Source: https://growth.rcpch.ac.uk/products/python-library Install the rcpchgrowth package into your Python project using pip. ```bash pip install rcpchgrowth ``` -------------------------------- ### Install development packages on Ubuntu/Linux Mint Source: https://growth.rcpch.ac.uk/developer/api-python Installs essential development header packages required for compiling Python from source with pyenv on Ubuntu/Linux Mint. ```bash sudo apt-get install liblzma-dev libbz2-dev zlib1g-dev ``` -------------------------------- ### Install RCPCHgrowth with Notebook Dependencies Source: https://growth.rcpch.ac.uk/researchers/introduction Install the RCPCHgrowth package along with optional notebook-related dependencies. This is recommended if you plan to use the provided Jupyter notebooks. ```bash pip install rcpchgrowth['notebook'] ``` -------------------------------- ### Example of Truncated API Response Source: https://growth.rcpch.ac.uk/integrator/making-api-calls This is an example of a truncated JSON response from the API, showing the structure of the returned data. ```json {"birth_data":{"birth_date":"2020-04-12", ... :{"events_text":["Growth hormone start","Growth Hormone Deficiency diagnosis"]}} ``` -------------------------------- ### Run Docker Container with Local Package Installation Source: https://growth.rcpch.ac.uk/developer/api-docker Use the 's/dev' script to create a Docker container that installs a local version of RCPCHGrowth as an editable package, useful for testing local modifications without PyPi deployment. Ensure the RCPCHGrowth package folder is parallel to the server folder. ```bash s/dev ``` -------------------------------- ### Clone the documentation repository Source: https://growth.rcpch.ac.uk/developer/writing-documentation Clone the repository to your local machine to begin editing documentation offline. Ensure Git is installed. ```bash git clone https://github.com/rcpch/digital-growth-charts-documentation.git ``` -------------------------------- ### Install Development Version Locally Source: https://growth.rcpch.ac.uk/developer/rcpchgrowth-cli Install the development version of the library locally using pip for testing changes. This allows immediate reflection of local code modifications in the CLI tool. ```bash pip install -e . ``` -------------------------------- ### Install Python Version with pyenv Source: https://growth.rcpch.ac.uk/developer/api-python Install Python version 3.12.0 using pyenv. This ensures the correct version of Python is available for the project. ```bash pyenv install 3.12.0 ``` -------------------------------- ### Install Python with Big Sur patch Source: https://growth.rcpch.ac.uk/developer/api-python Installs a specific Python version (3.8.0) using pyenv with a patch from a GitHub commit, intended for Big Sur compatibility. ```bash pyenv install --patch 3.8.0 < <(curl -sSL https://github.com/python/cpython/commit/8ea6353.patch\?full_index\=1) ``` -------------------------------- ### Render Chart Without React Source: https://growth.rcpch.ac.uk/integrator/using-the-chart-component This example demonstrates how to use the RCPCH Growth Charts component without a React framework. It shows how to import the library via CDN and render a chart by providing configuration options to the `RCPCHGrowthCharts.render` function. ```html Growth Chart Example
``` -------------------------------- ### Formatted JSON Response Example Source: https://growth.rcpch.ac.uk/integrator/making-api-calls A nicely formatted JSON response object after processing with `jq`, illustrating the structured data returned by the API. ```json { "birth_data": { "birth_date": "2020-04-12", "gestation_weeks": 40, ... # truncated "events_text": [ "Growth hormone start", "Growth Hormone Deficiency diagnosis" ] } } ``` -------------------------------- ### Set environment variable for pip requirements installation on Big Sur Source: https://growth.rcpch.ac.uk/developer/api-python Sets the SYSTEM_VERSION_COMPAT environment variable to 1, which may be required for pip to correctly install requirements on Big Sur. ```bash export SYSTEM_VERSION_COMPAT=1 ``` -------------------------------- ### Linear Interpolation using SciPy Source: https://growth.rcpch.ac.uk/clinician/how-the-api-works This example shows the use of SciPy's `interp1d` function for linear interpolation. It's employed when a child's measurement is close to a reference threshold and only one age point is available above or below. ```python from scipy.interpolate import interp1d # Example usage: # f = interp1d([x0, x1], [y0, y1]) # f(x) ``` -------------------------------- ### Run Storybook for Charts Package Source: https://growth.rcpch.ac.uk/developer/react-component Launch Storybook to develop and preview the chart components locally. ```bash npm run storybook ``` -------------------------------- ### Navigate to the cloned directory Source: https://growth.rcpch.ac.uk/developer/writing-documentation Change into the newly cloned directory to access the documentation project files. This is a necessary step after cloning. ```bash cd digital-growth-charts-documentation ``` -------------------------------- ### Navigate to the Project Directory Source: https://growth.rcpch.ac.uk/developer/api-python Change your current directory to the root of the cloned repository. This is necessary for subsequent commands to work correctly. ```bash cd digital-growth-charts-server ``` -------------------------------- ### Build and Run Docker Container for Development Source: https://growth.rcpch.ac.uk/developer/api-docker Use the 's/up' script to build the Docker image with dependencies and run it in a container for rapid development. The server will be available at https://localhost:8000. ```bash s/up ``` -------------------------------- ### Navigate to Code Projects Directory Source: https://growth.rcpch.ac.uk/developer/react-client Change the current directory to your code projects folder. This is the first step before cloning the repository. ```bash cd YourCodeProjects ``` -------------------------------- ### Clone the Server Repository Source: https://growth.rcpch.ac.uk/developer/api-docker Clone the digital growth charts server repository to your local machine to begin local development. ```bash git clone https://github.com/rcpch/digital-growth-charts-server.git ``` -------------------------------- ### Change directory Source: https://growth.rcpch.ac.uk/developer/api-python Navigates into the cloned digital-growth-charts-server directory. ```bash cd digital-growth-charts-server ``` -------------------------------- ### Navigate back to root directory Source: https://growth.rcpch.ac.uk/developer/api-python Navigates from the 'Scripts' directory back to the root directory of the project. ```bash cd .. cd .. ``` -------------------------------- ### Set environment variables for macOS Big Sur Python 3.12.0 installation Source: https://growth.rcpch.ac.uk/developer/api-python Sets CFLAGS and LDFLAGS environment variables to include necessary paths for libraries like openssl, bzip2, readline, and zlib when installing Python 3.12.0 on macOS Big Sur via pyenv. ```bash export CFLAGS="-I$(brew --prefix openssl)/include -I$(brew --prefix bzip2)/include -I$(brew --prefix readline)/include -I$(xcrun --show-sdk-path)/usr/include" export LDFLAGS="-L$(brew --prefix openssl)/lib -L$(brew --prefix readline)/lib -L$(brew --prefix zlib)/lib -L$(brew --prefix bzip2)/lib" ``` -------------------------------- ### Recompile Python with pyenv Source: https://growth.rcpch.ac.uk/developer/api-python Recompiles a specific Python version using pyenv, typically after installing development header packages. ```bash pyenv install 3.8.3 ``` -------------------------------- ### Build Docker Image Source: https://growth.rcpch.ac.uk/developer/react-client Build the Docker image for the React client. This command is used to create the container environment. ```bash s/docker-rebuild ``` -------------------------------- ### Navigate to Scripts directory Source: https://growth.rcpch.ac.uk/developer/api-python Changes the current directory to the 'Scripts' folder within the virtual environment, where activation scripts are located. ```bash cd env/Scripts ``` -------------------------------- ### Activate virtual environment on Windows Source: https://growth.rcpch.ac.uk/developer/api-python Runs the activate.bat script to activate the virtual environment. The command prompt should prepend '(env)' upon successful activation. ```batch activate.bat ``` -------------------------------- ### Make Scripts Executable Source: https://growth.rcpch.ac.uk/developer/api-docker Ensure development scripts are executable. Use 'chmod +x ' for *nix environments or WSL. ```bash chmod +x ``` -------------------------------- ### Create a virtual environment on Windows Source: https://growth.rcpch.ac.uk/developer/api-python Creates a new virtual environment named 'env' using the 'venv' module. Ensure 'env' is used consistently in subsequent commands. ```bash py -m venv env ``` -------------------------------- ### Create a Virtual Environment with pyenv Source: https://growth.rcpch.ac.uk/developer/api-python Create a virtual environment named 'dgc-server' using Python 3.12.0. This isolates project dependencies. ```bash pyenv virtualenv 3.12.0 dgc-server ``` -------------------------------- ### Enable Git Committers and PDF Export for Local Development Source: https://growth.rcpch.ac.uk/developer/writing-documentation Use these environment variables to enable specific plugins during local development. This helps in testing plugin functionality before pushing changes. ```bash export ENABLE_GIT_COMMITTERS=true; zensical serve export ENABLE_PDF_EXPORT=true; zensical serve ``` -------------------------------- ### Open React Client in Browser Source: https://growth.rcpch.ac.uk/developer/react-client Access the React client application by opening it in your web browser. The default address is http://localhost:3000. ```bash open http://localhost:3000 ``` -------------------------------- ### Git Branch-based Code Promotion Strategy Source: https://growth.rcpch.ac.uk/safety/csmf/clinical-risk-mgmt-plan Describes the standard 'code promotion' process using a Git Branch-based strategy for deploying changes. New features are developed in separate branches, reviewed, and merged through stages like 'test' before reaching the 'live' branch. ```text New features are developed in branches specific to that feature. Following successful testing, user acceptance, and automated tests, a successful feature can be merged into the next branch 'up' which may be a `test` branch or other nomenclature. The process of merging requires code review by nominated individuals and is a further opportunity for clinical safety review. Code in the `live` branch is changed relatively infrequently (except for urgent security or safety updates) but the code which is promoted into `live` would have by then undergone several rounds of review as it progressed through our branch promotion strategy. ``` -------------------------------- ### Create Pyenv Virtual Environment Source: https://growth.rcpch.ac.uk/developer/rcpchgrowth-cli Create a virtual environment named 'rcpchgrowth-python-cli' using Pyenv with Python 3.10.2. ```bash pyenv virtualenv 3.10.2 rcpchgrowth-python-cli ``` -------------------------------- ### Activate pyenv virtualenv Source: https://growth.rcpch.ac.uk/developer/api-python Activates a specific pyenv virtual environment. Ensure the virtualenv is created before activation. ```bash pyenv activate dgc-server ``` -------------------------------- ### API Credentials Configuration Source: https://growth.rcpch.ac.uk/products/flutter-app Store API base URL and key in a .env file at the project root. Ensure credentials are not committed to version control. ```dotenv DGC_BASE_URL=https://api.rcpch.ac.uk/growth/v1 DGC_API_KEY="YOUR-API_KEY" ``` -------------------------------- ### Clone React Client Repository Source: https://growth.rcpch.ac.uk/developer/react-client Clone the official dGC React Client repository from GitHub. This command downloads the project's source code. ```bash git clone https://github.com/rcpch/digital-growth-charts-react-client.git ``` -------------------------------- ### Generate and Store Chart Data with Overwrite Source: https://growth.rcpch.ac.uk/developer/versioning This Python snippet demonstrates how to call the `generate_and_store_chart_data` function with the `overwrite=True` argument to rebuild all centile data files, even if they already exist. This is useful for forcing a regeneration of reference data. ```python from main import generate_and_store_chart_data generate_and_store_chart_data(overwrite=True) ``` -------------------------------- ### Measurement Class Optional Parameters Source: https://growth.rcpch.ac.uk/developer/rcpchgrowth These parameters can be optionally provided during Measurement class initialization. If not provided, they default to None. Bone age related parameters are optimized for chart plugins. ```python bone_age: float bone_age_centile: float bone_age_sds: float bone_age_text: str bone_age_type ["greulich-pyle", 'tanner-whitehouse-ii', 'tanner-whitehouse-iii', 'fels'] events_text: list of str ``` -------------------------------- ### Run Postman Collection with Newman Source: https://growth.rcpch.ac.uk/developer/api-testing Execute a Postman collection against a local API using Newman. This command specifies the collection URL and sets an environment variable for the base URL. ```bash newman run https://www.getpostman.com/collections/e1ac5fe1fef92761c2ed --env-var "baseUrl=localhost:8000" ``` -------------------------------- ### Import RCPCHgrowth Package Source: https://growth.rcpch.ac.uk/researchers/introduction Import the RCPCHgrowth package into your Python script or Jupyter notebook to access its calculation functions. ```python import rcpchgrowth ```