Skip to content

doc: matlab example - parameterize wrapper, document Individual license workflow#589

Closed
llueg wants to merge 6 commits into
mainfrom
laurens/matlab-experiments
Closed

doc: matlab example - parameterize wrapper, document Individual license workflow#589
llueg wants to merge 6 commits into
mainfrom
laurens/matlab-experiments

Conversation

@llueg

@llueg llueg commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Generalize the matlab-springmass example so other users can run it
with their own MATLAB license:

  • Dockerfile.matlab-base is now parameterized with MATLAB_RELEASE
    and MATLAB_USERNAME build args (was hardcoded).
  • README now covers both network license (primary path) and
    MATLAB Individual license file workflows.
  • The Individual license path requires renaming the ubuntu user
    inside the container — recent MATLAB releases pick ubuntu out of
    /etc/passwd for the file-based license check regardless of the
    actual running UID. Renaming it to the username your license
    authorizes lets the check succeed. Rationale documented in the
    Dockerfile comment.
  • Fix existing run/serve examples in the README: --runtime-args
    was used where --docker-args/--env apply, and payloads were
    missing the {"inputs": ...} wrapper.

Test plan

Tested end-to-end with an Individual license. Network license path is
documented based on the previous README but not retested here.

🤖 Generated with Claude Code

llueg and others added 2 commits May 12, 2026 16:12
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@llueg llueg changed the title doc(matlab): parameterize wrapper, document Individual license workflow doc: parameterize wrapper, document Individual license workflow May 13, 2026
@codecov

codecov Bot commented May 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.08%. Comparing base (7cdeb0b) to head (e777201).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #589      +/-   ##
==========================================
- Coverage   77.13%   77.08%   -0.05%     
==========================================
  Files          32       32              
  Lines        4495     4495              
  Branches      739      739              
==========================================
- Hits         3467     3465       -2     
- Misses        726      728       +2     
  Partials      302      302              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@llueg llueg changed the title doc: parameterize wrapper, document Individual license workflow doc: matlab example - parameterize wrapper, document Individual license workflow May 13, 2026
ARG MATLAB_RELEASE
ARG MATLAB_USERNAME=matlab-user
USER root
RUN sed -i "s/^ubuntu:/${MATLAB_USERNAME}:/" /etc/passwd /etc/group

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could something like this technically be done from inside tesseract_api.py at startup? That is, (1) inspect the license file to find out which username it belongs to; (2) manipulate the runtime environment so the username matches? Or maybe even change the username in the release file via text substitution?

(This has a few too many manual steps for my taste, but if it's the best we can do it's what it is.)

@llueg llueg May 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually was possible with some tweaks, see the latest changes. We need the root user to rename the relevant files in /etc/passwd. One thing I noticed: tesseract build failed for me with the standard Matlab image as base, since it doesn't have root user by default, so the apt-get in Dockerfile.base failed. I added the root user there now - Claude said this was fine since we change it back at the end anyway, and might be useful for other non-root base images. Let me know what you think. It's weird though that this didn't occur in your original PR on this, since you were also using the default Matlab base image. I checked and 2025b also doesn't have a default root user..
Edit: The root issue will also be fixed in #598 .

@llueg llueg May 18, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and you can read the username from the license file, it's in there in hexadecimal (along with the mac address). Changing the mac address at runtime is a little clunky so I would vote to stick with explicit arguments for both, but I can add it if you think it best.

@PasteurBot

Copy link
Copy Markdown
Contributor

Benchmark Results

Benchmarks use a no-op Tesseract to measure pure framework overhead.

🚀 0 faster, ⚠️ 5 slower, ✅ 31 unchanged

Notable changes

Benchmark Baseline Current Change Status
cli/apply_1,000 1631.051ms 2060.859ms +26.4% ⚠️ slower
cli/apply_100,000 1651.444ms 1948.727ms +18.0% ⚠️ slower
cli/apply_10,000,000 1701.238ms 2041.576ms +20.0% ⚠️ slower
http/apply_1,000 2.871ms 3.951ms +37.6% ⚠️ slower
http/apply_100,000 8.103ms 10.467ms +29.2% ⚠️ slower
Full results
Benchmark Baseline Current Change Status
api/apply_1,000 0.501ms 0.497ms -0.8%
api/apply_100,000 0.498ms 0.499ms +0.3%
api/apply_10,000,000 0.506ms 0.501ms -1.0%
cli/apply_1,000 1631.051ms 2060.859ms +26.4% ⚠️ slower
cli/apply_100,000 1651.444ms 1948.727ms +18.0% ⚠️ slower
cli/apply_10,000,000 1701.238ms 2041.576ms +20.0% ⚠️ slower
decoding/base64_1,000 0.029ms 0.029ms -0.9%
decoding/base64_100,000 0.739ms 0.727ms -1.5%
decoding/base64_10,000,000 75.929ms 73.819ms -2.8%
decoding/binref_1,000 0.184ms 0.187ms +1.1%
decoding/binref_100,000 0.234ms 0.235ms +0.3%
decoding/binref_10,000,000 10.911ms 11.210ms +2.7%
decoding/json_1,000 0.099ms 0.099ms -0.1%
decoding/json_100,000 9.508ms 9.529ms +0.2%
decoding/json_10,000,000 1136.497ms 1135.492ms -0.1%
encoding/base64_1,000 0.028ms 0.028ms +1.8%
encoding/base64_100,000 0.143ms 0.144ms +1.1%
encoding/base64_10,000,000 24.573ms 23.558ms -4.1%
encoding/binref_1,000 0.277ms 0.274ms -0.9%
encoding/binref_100,000 0.447ms 0.450ms +0.8%
encoding/binref_10,000,000 18.151ms 18.156ms +0.0%
encoding/json_1,000 0.142ms 0.143ms +1.1%
encoding/json_100,000 15.370ms 15.186ms -1.2%
encoding/json_10,000,000 1526.460ms 1527.500ms +0.1%
http/apply_1,000 2.871ms 3.951ms +37.6% ⚠️ slower
http/apply_100,000 8.103ms 10.467ms +29.2% ⚠️ slower
http/apply_10,000,000 697.750ms 697.806ms +0.0%
roundtrip/base64_1,000 0.058ms 0.058ms +1.1%
roundtrip/base64_100,000 0.768ms 0.766ms -0.3%
roundtrip/base64_10,000,000 101.736ms 100.210ms -1.5%
roundtrip/binref_1,000 0.476ms 0.477ms +0.2%
roundtrip/binref_100,000 0.688ms 0.683ms -0.7%
roundtrip/binref_10,000,000 30.361ms 29.104ms -4.1%
roundtrip/json_1,000 0.248ms 0.247ms -0.5%
roundtrip/json_100,000 22.346ms 21.349ms -4.5%
roundtrip/json_10,000,000 2673.340ms 2699.292ms +1.0%
  • Runner: Linux 6.17.0-1013-azure x86_64

Comment on lines +115 to +117
as that user. This is required because MATLAB's file-based license
check picks the `ubuntu` entry out of `/etc/passwd` regardless of the
actual running UID — renaming it lets the check see the correct user.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this sentence. Why would it pick out ubuntu? Doesn't it look for <your-username>?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For some reason, if we don't rename the ubuntu entry, I got an error along the lines of "User ubuntu is not authorized to use this license", regardless of which user name/id I pass to the container.

@dionhaefner

Copy link
Copy Markdown
Contributor

Closing for now, it seems that MathWorks doesn't support using personal licenses from Docker containers, and the solutions here feel too hacky for an official guide.

Happy to revisit once there's official support on the MATLAB side.

@pasteurlabs pasteurlabs locked and limited conversation to collaborators May 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants