Package: obflib
OBFlib-PythonOBFlib-Python is a Python library for verifying, reading and manipulating OBF files. It also has an
accompanying command-line utility,obftool.OBF (Open Build File) is a format that works as a blueprint and recipe for building objects in an
electron beam powder bed fusion (E-PBF) 3D printer.InstallationBullseyeOBFlib-Python can be installed as a Debian package on Debian Bullseye. The package resides in the
public apt repository:echo"deb http://apt.opensource.freemelt.com/debian bullseye main"|sudotee-a/etc/apt/sources.list.d/freemelt.list>/dev/null
curlhttp://apt.opensource.freemelt.com/debian/archive.gpg.key|sudotee/etc/apt/trusted.gpg.d/freemelt-opensource.gpg>/dev/null

sudoaptupdate
sudoaptinstallpython3-obflibNOTE: The above commands for installation on Debian Bullseye currently do not work since there is no
working pipeline for publishing to the Bullseye channel on the public apt repository. It should
however work to just replacebullseyewithbusterin the first command, since the same OBFLib
package works on both Buster on Bullseye.Debian BusterOBFlib-Python can also be installed as a Debian package on Debian Buster but requires extra steps.echo"deb http://apt.opensource.freemelt.com/debian buster main"|sudotee-a/etc/apt/sources.list.d/freemelt.list>/dev/null
curlhttp://apt.opensource.freemelt.com/debian/archive.gpg.key|sudotee/etc/apt/trusted.gpg.d/freemelt-opensource.gpg>/dev/nullecho'deb http://deb.debian.org/debian buster-backports main'|sudotee-a/etc/apt/sources.list>/dev/nullecho'deb http://deb.debian.org/debian bullseye main'|sudotee-a/etc/apt/sources.list>/dev/null

sudotee/etc/apt/preferences.d/buster-first.pref>/dev/null<< EOFPackage: *Pin: release n=bullseyePin-Priority: -1Package: python3-jsonschemaPin: release n=buster-backportsPin-Priority: 500Package: python3-semantic-versionPin: release n=bullseyePin-Priority: 500EOFsudoaptupdate
sudoaptinstallpython3-obflibObflib can also be installed through pip viaGitLab's internal package registry.pip3install--index-urlhttps://gitlab.com/api/v4/projects/33702591/packages/pypi/simpleobflibAPI DocumentationOnce obflib is installed as a Debian package, its API documentation can be viewed with the following
command:obftoolapi-docsUsageObflib can be used as a Python library or with the command-line toolobftool.Python example>>> import obflib
>>> messages = obflib.verify("openbuildfile/examples/standard.obf")
>>> messages.to_json()
'{"errors": {}, "warnings": {}, "isValid": true}'
>>> messages.is_valid()
True
>>> with obflib.OBF("openbuildfile/examples/standard.obf") as obf:
...     manifest = obf.manifest()
...     build_info = obf.build_info()
...
>>> manifest['name']
'Test Rod'
>>> len(build_info['layers'])
2Command-line examplesVerify an OBF:> obftool verify openbuildfile/examples/standard.obf
The file openbuildfile/examples/standard.obf appears to be a valid OBF file.
> obftool verify openbuildfile/examples/invalid.obf
ERRORS in openbuildfile/examples/invalid.obf:
manifest.json/modules/defect-detector: 'modules/freemelt_defect_detector/modulez.json' does not exist in the OBF
manifest.json: 'version' is a required property
buildInfo.json/files/preHeat: 'nonexistent-file.obp' does not exist in the OBF
buildInfo.json/files/file7: 'obp/file7.obp' does not exist in the OBF
buildProcessors/buildProcessors.json/buildProcessors/simple/version: 'latest' is not a valid npm semver range. See https://github.com/npm/node-semver#ranges.
buildProcessors/buildProcessors.json/buildProcessors/complexer/entryPoint: 'buildProcessors/bob/bob-complex.lua' does not exist in the OBF
buildProcessors/buildProcessors.json/buildProcessors/complexer/args: '[amount=40]' is not of type 'array'
machineCapabilities.json/buildModule/platform: 760 is not of type 'object'
modules/freemelt_nir_thermometer/module.json: 'author' is a required property

Warnings in openbuildfile/examples/invalid.obf:
manifest.json/author: This recommended property is missing
manifest.json/license: This recommended property is missing
modules/freemelt_nir_thermometer/module.json: An object in this file contains duplicates of the key 'license'
modules/freemelt_defect_detector/module.json: This file appears to be unused

The file openbuildfile/examples/invalid.obf is not a valid OBF file.Converting a BOSS configuration to an OBF using the proof-of-concept converter:> obftool convert path/to/BOSS_files/ converted.obf
Adding obp: path/to/BOSS_files/TestBars11Layer1.obp
Adding obp: path/to/BOSS_files/TestBars13Layer1.obp
Adding obp: path/to/BOSS_files/TestBars7Layer1.obp
Adding obp: path/to/BOSS_files/preheat.obp
Adding obp: path/to/BOSS_files/plateheat.obp
Adding obp: path/to/BOSS_files/TestBars0Layer1.obp
Adding obp: path/to/BOSS_files/TestBars3Layer1.obp
Adding obp: path/to/BOSS_files/TestBars6Layer1.obp
Adding obp: path/to/BOSS_files/TestBars15Layer1.obp
Adding obp: path/to/BOSS_files/TestBars1Layer1.obp
Adding obp: path/to/BOSS_files/TestBars14Layer1.obp
Adding obp: path/to/BOSS_files/TestBars10Layer1.obp
Adding obp: path/to/BOSS_files/TestBars9Layer1.obp
Adding obp: path/to/BOSS_files/TestBars4Layer1.obp
Adding obp: path/to/BOSS_files/TestBars2Layer1.obp
Adding obp: path/to/BOSS_files/TestBars12Layer1.obp
Adding obp: path/to/BOSS_files/TestBars5Layer1.obp
Adding obp: path/to/BOSS_files/TestBars8Layer1.obp
Adding obp: path/to/BOSS_files/postheat.obp
Done! Wrote OBF to 'converted.obf'.Converting a BOSS configuration to an OBF using the proof-of-concept converter with a custom Lua
script and setting a custom name:> obftool convert path/to/BOSS_files/ converted.obf --bob-script example=build.lua --name 'Custom Build'
Using name 'Custom Build'
Using build script 'build.lua' as 'example'
Adding obp: path/to/BOSS_files/TestBars11Layer1.obp
Adding obp: path/to/BOSS_files/TestBars13Layer1.obp
Adding obp: path/to/BOSS_files/TestBars7Layer1.obp
Adding obp: path/to/BOSS_files/preheat.obp
Adding obp: path/to/BOSS_files/plateheat.obp
Adding obp: path/to/BOSS_files/TestBars0Layer1.obp
Adding obp: path/to/BOSS_files/TestBars3Layer1.obp
Adding obp: path/to/BOSS_files/TestBars6Layer1.obp
Adding obp: path/to/BOSS_files/TestBars15Layer1.obp
Adding obp: path/to/BOSS_files/TestBars1Layer1.obp
Adding obp: path/to/BOSS_files/TestBars14Layer1.obp
Adding obp: path/to/BOSS_files/TestBars10Layer1.obp
Adding obp: path/to/BOSS_files/TestBars9Layer1.obp
Adding obp: path/to/BOSS_files/TestBars4Layer1.obp
Adding obp: path/to/BOSS_files/TestBars2Layer1.obp
Adding obp: path/to/BOSS_files/TestBars12Layer1.obp
Adding obp: path/to/BOSS_files/TestBars5Layer1.obp
Adding obp: path/to/BOSS_files/TestBars8Layer1.obp
Adding obp: path/to/BOSS_files/postheat.obp
Done! Wrote OBF to 'converted.obf'.ContributingOBFlib-Python uses docker compose to set up a development environment. Follow the below steps
for getting started with contributing to OBFlib-Python.PrerequisitesFirst install Docker and Docker Compose. If you are on Ubuntu, the following steps should do it:sudoaptremovedockerdocker-enginedocker.iocontainerdrunc
sudoaptupdate
sudoaptinstallca-certificatescurlgnupglsb-release
sudomkdir-p/etc/apt/keyrings
curl-fsSLhttps://download.docker.com/linux/ubuntu/gpg|sudogpg--dearmor-o/etc/apt/keyrings/docker.gpgecho\"deb [arch=$(dpkg--print-architecture)signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \$(lsb_release-cs)stable"|sudotee/etc/apt/sources.list.d/docker.list>/dev/null
sudoaptupdate
sudoaptinstalldocker-cedocker-ce-clicontainerd.iodocker-compose-plugin
sudousermod-aGdocker$USERThe last line above is needed in order to run the tests without password.
To get the added group working for your user, you can log out and in, or:execsu-l$USERSet up the development environmentSet up the basic development environment using the following command:makeprepare-devNote: You might have to add pip's user site bin directory to$PATHfor the above command to work.
On e.g. Ubuntu, this is done by adding the following line to~/.bashrcor equivalent:export PATH=~/.local/bin:$PATHIn general, commands for running tests, linting, etc. should be run in the Docker container started
bymake prepare-dev. This can be accomplished in (at least) two ways: Either by entering a bash
shell inside the container:makeenter-dockerOr by running just the desired command inside the container:dockercomposeexecdebian<command>TestingTest any changes by running the command:make testLintingCheck code style and formatting with the following command:make lintThese checks will also be performed automatically on each commit with the pre-commit hooks that are
installed withmake prepare-dev.Generating API documentationThe API documentation can be generated and previewed withdocker compose exec debian make api-docs
xdg-open api-docs/index.htmlThe API documentation is also built automatically for every CI pipeline. The above command therefore
does not normally need to be run unless you need the documentation locally.ReleasingAll new commits are built and packaged to be published on the public Debian repository on the
unstable "branch".To publish a packaged stable version of the library, tag it (use-afor an annotated tag) and a
Debian package will be published on the public Debian repository on the stable "branch". For this
to trigger, the tag must start withv. Updatedebian/changelogusingdchbefore releasing. For
example:dch--newversion0.5.0-Dstable-m
gitcommit...# First, commit as usualgittag-av0.5.0
gitpush--follow-tagsDependenciesWhen adding dependencies to the project, they are to be added both in setup.py as pip packages and
in Dockerfile as debian packages. In the dockerfile they are to be added alongside the other debian
packages.The dh-python tool translates the dependencies in setup.py to debian package names when we build a
deb package. The duplication between setup.py and the Dockerfile is to ensure that the development
environment is using the same versions as the actual machine.CIThe CI environment currently has no mechanism for building the Docker image as part of the pipeline.
Thus, the image used in CI needs to be kept up-to-date manually.Whenever a change is made in the dockerfiles or related files, rebuild and push the Docker images
withmakedocker-pushIDE setupVS CodeMake sure that there is no venv folder in the directory and
installRemote - ContainersTo open the directory through docker press ctrl+shift+p and write the
commandRemote-Containers: Open Folder in Container....This enables testing and debugging through VSCode in the docker container. Testing can be easily
configured by following the steps in the testing panel.PyCharmFor proper integration with PyCharm, the Professional version is needed.You also need to have the commanddocker-composeversion installed, as opposed to the newer version which is invoked
withdocker compose(notice the space). If you installed Docker through the official APT repository on Ubuntu, this
can be accomplished by just installing the packagedocker-compose. Both versions can coexist without any problems.To set it up,add a new interpreterby going toSettings->Project: nir-temperature-sensor->Python Interpreterand clicking at the settings icon and thenAdd. Then selectDocker Compose. If necessary, add a Docker server (the default settings should be fine
if you're not doing anything special). SetServicetodebianandPython interpreter pathtopython3.Now you should be able to run scripts and tests, as well as debug them, from within PyCharm.
Note that whenever you start a script (including any test), PyCharm restarts the Docker Compose service running the gRPC
server. This means that you will have to start it again afterwards if you want it to keep running.