Skip to main content

Random-data generator to simulate fictional port data flows for use at a Hackathon

Project description

Mooring Data Generator

A simple script to generate fake mooring data for use in a hackathon. This script will send data payloads to and endpoint to simulate the data which might exist.

These will be http POST queries to the url provided as an argument at run time.

The script will run forever until the user sends a Ctrl+C command to end the script.

Install

With UV (recommended)

If you don't have UV on your system, read the install instructions for UV

uv tool install -U mooring-data-generator

Vanilla python (If you don't want UV)

pip install -U mooring-data-generator

Usage

Running the package

Sending data via HTTP POST

mooring-data-generator http://127.0.0.1:8000/my/endpoint/

[!IMPORTANT] replace http://127.0.0.1:8000/my/endpoint/ with the appropriate url for your system

Saving data to a file

You can also save the generated mooring data to a JSON file instead of sending it via HTTP:

mooring-data-generator --file output.json

This will continuously generate mooring data and save it to the specified file.

[!NOTE] You can only use either the URL (HTTP POST) or --file option, not both at the same time

Getting the OpenAPI specification

You can output an OpenAPI 3.0 specification for the mooring data format:

mooring-data-generator --openapi

This will print a complete OpenAPI specification in JSON format that describes the structure of the mooring data being generated. This is useful for:

  • Understanding the data format
  • Generating client libraries
  • API documentation
  • Integration planning

The specification can be saved to a file for use with OpenAPI tools:

mooring-data-generator --openapi > openapi.json

Testing data is being sent

There's a helper application included in this package to allow you to check that the data is being sent.

mooring-data-receiver will display to the console all http traffic it receives.

mooring-data-receiver

By default it will run listening to any traffic 0.0.0.0 on port 8000

You can adjust this if needed by using a commend like

mooring-data-receiver --host 127.0.0.1 --port 5000

Formatting output

You can use the --format flag to control how the request body is displayed:

mooring-data-receiver --format

When --format is used, the request body content will be formatted using json.dumps(indent=2) for better readability. Without this flag, the content is displayed as received.

Troubleshooting

Command not found

If you are having trouble with the command not being found, you can attempt to run it as a module calling python

python -m mooring-data-generator http://127.0.0.1:8000/my/endpoint/

Pip not found

If pip can't be found on your system.

First, make sure you have Python installed.

python --version

you can call pip from python directly as a module.

python -m pip install -U mooring-data-generator

Release a new version

Be sure the tests pass

uv sync --all-groups
uv run ruff format
uv run ruff check
uv run tox

bump version and tag new release

uv version --bump minor
git commit -am "Release version v$(uv version --short)"
git tag -a "v$(uv version --short)" -m "v$(uv version --short)"

push to github

git push
git push --tags

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mooring_data_generator-0.11.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mooring_data_generator-0.11.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file mooring_data_generator-0.11.0.tar.gz.

File metadata

File hashes

Hashes for mooring_data_generator-0.11.0.tar.gz
Algorithm Hash digest
SHA256 aa4b601d18ed414a444cf8bbe77ea13c4518ee5240b43f0da76138cb5cb2dd4d
MD5 c6a924fe1ba5b462a5e3964f606e9faa
BLAKE2b-256 395a808f4e844f3d5a3875cc7b8ad345112a4b25862124a2ff13468efd70b0f7

See more details on using hashes here.

File details

Details for the file mooring_data_generator-0.11.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mooring_data_generator-0.11.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e5e6c1f500ea89d3617c8ac71ac4fb397d2395b70d1970d7483e39ca0cfd3647
MD5 d711f49901f36c0bfe7f369dce222df9
BLAKE2b-256 0f25f698db4933287b84d2f9aa0ba154c23155e95cb00d9dd1c795974bd725d1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page