Skip to main content

tosca-core

A parser and semantic validator for TOSCA 2.0 and the TOSCA Simple Profile in YAML 1.3, with Simple Profile 1.0 to 1.2 accepted and validated as 1.3.

tosca-core reads service templates and profiles, packaged as CSARs, as CSAR directories or as single YAML files. It builds a model of the types, declarations and templates they define, resolves imports and derived_from against a catalog of profiles, evaluates the functions TOSCA defines, and checks the result against TOSCA's rules. Deploying what a template describes is the work of an application that embeds tosca-core, which can extend validation with what it knows about running artifacts.

The public API, what stays stable from one release to the next, is in docs/api.md.

Install

pip install tosca-core
pip install "tosca-core[flask]"   # when serving the model through a Flask REST API

The flask extra only matters to an application that serves the model over HTTP: dump-only URL fields link entities to its resources, and without Flask they are omitted.

Python 3.10 or later. tosca-core keeps its catalog in a database through SQLAlchemy. By default that is an in-memory SQLite database, so there is no server to run.

From a checkout, with the test dependencies:

pip install -e ".[test]"

Validate from the command line

tosca-validate validates from a shell, building the catalog once and caching it:

$ tosca-validate -p profiles svc/my-service
FAIL svc/my-service  (24ms)
       main.yaml:28  service_template › node_templates › client › properties › performance
           $get_property: ['SELF', 'RELATIONSHIP', 'server', 'CAPABILITY', 'quality'] not found

1 of 1 target(s) failed -- 1 error(s)

Each target is a CSAR, a CSAR directory or a single TOSCA file. The catalog holds the normative profiles and every profile under the trees given with -p (or TOSCA_CORE_PROFILES, separated like PATH). It is cached until the trees or tosca-core change: building it for a few dozen profiles takes tens of seconds, and a run against the cached catalog takes well under one.

Option
-p DIR, --profiles DIR a profile tree; repeatable
--only-profile GLOB, --exclude-profile GLOB build the catalog from some of the profiles; a target importing one left out is refused, not validated
--rebuild rebuild the cached catalog
--reset start from scratch: delete every cached catalog, then validate any targets
--catalog-info show the catalog the trees select, and what did not onboard and why
--skip-file-checks do not require the files that artifacts name to exist
-f json results as JSON, for CI
-q, -v no progress; or tosca-core's log as well

It exits 0 when every target is valid, 1 when any has a finding or cannot be read, and 2 for a usage error, a catalog that cannot be built, or a target a restricted catalog refused.

Validation evaluates the functions TOSCA defines, and only those. A function a profile implements with an artifact, such as the TOSCA community profile's $in_range, is left to an application that runs artifacts. A validation clause built on one is listed as not checked under its target, and does not make the target fail.

docs/validation.md covers the rest: reading the output and its JSON, giving profile trees, restricting the catalog, the cache, and what validation leaves to the application that deploys a template.

Validate from Python

From Python, validation needs a catalog holding the normative profiles, which every TOSCA definition ultimately derives from. Build one, then validate:

from tosca_core import (bootstrap, create_tables, load_normative_profiles,
                        session_scope, validate_csar)

bootstrap()                      # bind the database, load the models
with session_scope():
    create_tables()
with session_scope():
    load_normative_profiles()    # TOSCA 2.0 and Simple Profile 1.3

errors = validate_csar("service.yaml")
print(errors or "valid")

validate_csar persists nothing. It returns {} for a valid target, a string when the target cannot be read at all, and otherwise the errors as a nested dict that follows the structure of the documents (docs/api.md). A template that imports other profiles needs them onboarded first with onboard_csar, inside a session_scope() so they are committed.

To validate many templates in one process, call reset_session() between them, so that a validation that fails leaves nothing behind for the next.

Configuration

tosca-core reads its settings from tosca_core.constants.constants, which an application changes with configure(). From a shell:

Environment variable Sets
TOSCA_CORE_DB_URI the database (DB_URI); in-memory SQLite by default
TOSCA_CORE_DIR the working directory tosca-core reads and writes (WORK_DIR); tosca-core under XDG_CACHE_HOME, or ~/.cache/tosca-core, by default
TOSCA_CORE_LOCAL_REPOSITORY_ROOTS the directories outside a CSAR that a file: repository may name; absolute paths, separated like PATH; none by default
TOSCA_CORE_PROFILES tosca-validate's profile trees

Every setting is listed in docs/api.md.

A file-backed SQLite database (sqlite:////abs/path/catalog.db) keeps the catalog between runs, so the normative profiles are loaded once. A catalog is the database together with its working directory: the database records each onboarded CSAR by the absolute path it was unpacked to, under WORK_DIR. Keep the two together.

Embedding tosca-core

An application that deploys what tosca-core validates configures it at startup, builds its own runtime objects from the templates, and extends validation from the modules it lists in EXTENSION_MODULES: a check for every implementation artifact, an evaluator for functions profiles implement with artifacts, and a check for attributes an earlier operation writes. Where tosca-core evaluates a path against a service of instances, it asks that service to resolve the node a path names. The full contract is section 4 of docs/api.md.

Tests

pytest

tests/test_standalone.py checks, in a separate interpreter, that every module imports and a template validates with Flask and any embedding application unavailable.

Contributing

Report a problem or ask a question by opening an issue. Changes come as pull requests, with a test that pins what they fix and pytest passing. Report a security vulnerability privately, through the repository's Security tab, rather than in an issue.

License

Apache License 2.0; see LICENSE.

Metadata

Release files for tosca-core 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tosca-core 1.1.0
File Size Uploaded Provenance Actions
tosca_core-1.1.0.tar.gz 411.5 kB With provenance Details for tosca_core-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tosca-core 1.1.0
File Interpreter ABI Platform Actions
tosca_core-1.1.0-py3-none-any.whl Python 3 none any Details for tosca_core-1.1.0-py3-none-any.whl

Total release size: 900.7 kB

Release files / tosca_core-1.1.0.tar.gz

Download URL tosca_core-1.1.0.tar.gz
Size 411.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f179b0479369a90da2ae35cdf9b0570cffe1c086e2d859c0493efe9c72ee4307
BLAKE2b-256 checksum
How to use checksums
0a03ae557f473d90bceb5cdf505a6fdfd1e09b24377b9ff4885c805395dfcf42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / tosca_core-1.1.0-py3-none-any.whl

Download URL tosca_core-1.1.0-py3-none-any.whl
Size 489.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac167dfa0e76d7afb340469b756636b390b3f50bdef7ec287985f1a2de9689f3
BLAKE2b-256 checksum
How to use checksums
7f98da028c6997c7edc97538d2c280700bbf55f2d55364b7983ec9663ea2e252
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for tosca-core 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for tosca_core-1.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page