Skip to main content

Common platform for developing Open Source Ecology (OSE) workbenches.

Project description

OSE Workbench Platform

PyPI version Conda version Build Status Documentation Status Coverage Status

Introduction

A platform for developing workbenches for Open Source Ecology (OSE).

OSE defines a "workbench" as a set of tools in CAD software to design and make a particular machine.

Each workbench OSE develops for one of it's machines has certain common development-time or "dev-time" needs and dependencies.

For example, running unit tests, making documentation, and generating code to streamline workbench development.

Rather than duplicate the approaches to each of these needs, ose-workbench-platform abstracts those needs into a common platform so they aren't the concern of individual OSE workbench maintainers.

Each workbench maintainer doesn't need to know or care about the particular versions and libraries we use to solve those needs, nor the particular configuration.

Having a common platform for OSE workbench development also makes it easier for developers to readily switch between workbenches by providing a common tool-set.

ose-workbench-platform provides a command-line interface (CLI), via the osewb command, containing commands for common dev-time tasks such as running all tests, making documentation, initializing new workbenches, and even generating code for common tasks.

Pre-Requisites

  1. Install Git
  2. Install Miniconda

Installation

Install the ose-workbench-platform package from the gbroques channel in a dedicated conda environment named osewb (short for Open Source Ecology WorkBench) and don't ask for confirmation:

conda create --name osewb --channel gbroques --yes ose-workbench-platform

Activate your new osewb environment:

conda activate osewb

Test your installation:

osewb --help

You can deactivate this environment later by running:

conda deactivate

Virtual Development Environment

We use Conda to create a reproducible virtualized OSE workbench development environment with requisite dependencies for development-time tasks like running FreeCAD, executing unit tests, and generating documentation from source-code comments.

In order to perform various development-time tasks for a workbench, you must first:

  1. Create a conda environment from the environment.yml file located in the root of the workbench repository
  2. Activate the environment with conda activate <environment name>

Note, each workbench will have it's own separate environment.

Workbench environments will be named after the base package in the workbench repository (e.g. ose3dprinter, osetractor, osepowercube, etc.).

Some common commands relating to managing environments with conda are documented in the below table.

Description Command
Creating the environment conda env create --file environment.yml
Activating the environment conda activate <environment name>
Deactivating the environment conda deactivate

Refer to the Conda CLI reference documentation for additional information.

Unit Tests

For running unit tests we use pytest.

For test coverage, we use coverage.py and pytest-cov.

Documentation

For building documentation, we use Sphinx.

For hosting documentation, we use a free service for open-source projects called Read the Docs.

For a modern and mobile-friendly look, we use Read the Docs Sphinx Theme.

Commands

The osewb command contains various sub-commands for performing common dev-time tasks of a OSE workbench.

$ osewb -h ↵
usage: osewb <command> [<args>]

A collection commands for OSE workbench development.

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit

Commands:
  {test,lint,docs,make,browse,br}
    test                Run tests in workbench
    lint                Lint code
    docs                Make documentation
    make                Commands for making new code
    browse (br)         Commands for opening documents in a web browser

Each sub-command may have flags and arguments, and additional information can be discovered via osewb <command> -h or --help.

Is osewb too many characters to type? We recommend aliasing the osewb command as ose to reduce typing and increase speed even further.

For further convenience, any command over four characters shall include a short-alias under four characters or less. For example, br is the short-alias for the five-character browse command.

test

OSE Workbench Platform includes a test command for interacting with the test-suite of a workbench.

$ osewb test -h ↵
usage: osewb test

optional arguments:
  -h, --help      show this help message and exit
  -c, --coverage  Run tests with coverage, and generate report

To run the entire unit-test suite for a workbench, run:

osewb test

For running tests with coverage and generating a coverage report, pass the -c or --coverage flag to the test command:

osewb test --coverage

lint

OSE Workbench Platform includes a lint command for linting the code of a workbench.

osewb lint

The lint command will:

  • Run flake8 with configuration located in .flake8.
  • Run mypy for static type checking with configuration located in .mypy.ini.

For automatically fixing some linter issues, pass the -f or --fix flag to the lint command:

osewb lint --fix

This will run isort and autopep8 recursively on the root of the workbench repository.

For additional information, see:

docs

OSE Workbench Platform includes a docs command for building the documentation of a workbench.

$ osewb docs -h ↵
usage: osewb docs [command]

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

Commands:
  {screenshot,ss}
    screenshot (ss)
                   Take screenshots of parts for documentation.

The docs command will:

  • Remove auto-generated files such as the _build/ and any auto-generated Sphinx sources.
  • Re-generate docs/_build/, docs/<base package>/, docs/freecad/<base package>/ by running sphinx-build . _build within docs/ using the Sphinx configuration specified in docs/conf.py

For additional information, see sphinx-build and Sphinx Configuration.


Additionally, you may pass a screenshot or ss sub-command to the docs command for taking screenshots of parts in a workbench:

osewb docs ss

This will look for parts in the <base package>/part package of the current workbench, and save thumbnail screen shots in the docs/_static/screenshot/ directory for each part.

build

OSE Workbench Platform includes a build command for building a workbench.

osewb build

The build command aggregates the following commands into one:

  1. Run tests with coverage - osewb test --coverage
  2. Lint all code - osewb lint
  3. Ensure the documentation builds - osewb docs

The build command exits with 0 or 1 to pass or fail the build depending upon whether the above commands return non-zero exit codes.

make

OSE Workbench Platform includes a make command for "making" new code.

$ ose make -h ↵
usage: osewb make <command>

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

Commands:
  {workbench,wb,part,model}
    workbench (wb)      Make Workbench
    part                Make Part class
    model               Make Model class

workbench

Navigate to where you want to create your new workbench. Then run:

osewb make workbench <machine_display_name>

Where <machine_display_name> is the name of the machine in Title Case. If this contains spaces, then surround the value in double-quotes "".

$ osewb make workbench Tractor ↵
Workbench initialized in "ose-tractor-workbench" directory.

Perform the following commands to get started:

1. Change directories and initialize the git repository:

    cd ose-tractor-workbench && git init

2. Create a conda environment and activate it:

    conda env create --file environment.yml && conda activate osetractor

3. Verify your installation:

    osewb -h

The above examples initializes a new workbench, in a ose-tractor-workbench directory, with the basic structure and files needed.

$ tree ose-tractor-workbench --dirsfirst ↵
ose-tractor-workbench
├── docs
│   ├── conf.py
│   └── index.rst
├── freecad
│   └── osetractor
│       ├── command
│       │   ├── _add_box
│       │   │   ├── add_box_command.py
│       │   │   └── __init__.py
│       │   └── __init__.py
│       ├── icon
│       │   ├── Box.svg
│       │   └── __init__.py
│       ├── init_gui.py
│       ├── __init__.py
│       └── OSE_Tractor.py
├── osetractor
│   ├── part
│   │   ├── _box
│   │   │   ├── box.py
│   │   │   └── __init__.py
│   │   └── __init__.py
│   └── __init__.py
├── tests
│   ├── box_test.py
│   └── __init__.py
├── CONTRIBUTING.md
├── environment.yml
├── LICENSE
├── MANIFEST.in
├── README.md
└── setup.py

10 directories, 22 files

For more information, see the Pattern Catalog in the docs.

OSE Tractor Workbench

part

Within the repository of a workbench, run the osewb make part command to make a new Part Class.

For example,

osewb make part Box

Makes a new Box part class.

For more information, see Part Classes in the docs.

model

Within the repository of a workbench, run the osewb make model command to make a new Model Class.

For example,

osewb make model Box

Makes a new BoxModel model class.

For more information, see Model Classes in the docs.

browse

OSE Workbench Platform includes a browse covenience command for opening documentation and coverage reports in a web browser.

$ osewb browse -h ↵
usage: osewb browse <command>

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

Commands:
  {docs,coverage,cov}
    docs               Opens docs in web browser
    coverage (cov)     Opens coverage report in web browser

The docs command opens docs/_build/index.html in a web browser, while coverage opens htmlcov/index.html in a web browser.

Contributing

See Contributing Guidelines.

License

Licensed under the GNU Lesser General Public License, version 2.1 or LGPL v2.1. See LICENSE for details.

This is the same license as FreeCAD to ensure this code could potentially be incorporated into future FreeCAD modules or FreeCAD source itself.

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

ose-workbench-platform-0.1.0b1.tar.gz (57.5 kB view details)

Uploaded Source

File details

Details for the file ose-workbench-platform-0.1.0b1.tar.gz.

File metadata

  • Download URL: ose-workbench-platform-0.1.0b1.tar.gz
  • Upload date:
  • Size: 57.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.3

File hashes

Hashes for ose-workbench-platform-0.1.0b1.tar.gz
Algorithm Hash digest
SHA256 5bb6b7aa1d46ba16aacc0d7acc86bc7428468ebd8c794fd759a81f3ea2092263
MD5 a5cdc5f7e2ca9b35eb82e125d25f24dd
BLAKE2b-256 5e972d7591496836450ad51397e63e7798ed786bc07b1b9a59ab1976f3e0b02c

See more details on using hashes here.

Supported by

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