7. Data Sources#
A dataroot is registered with set_dataroot(name, path, tag=None), and
the scheme its path starts with picks what fetches it. These are the schemes
SiliconCompiler understands, and what each one takes.
design.set_dataroot("<name>", "<scheme>://<location>", tag="<version>")
Some rules hold for every source:
A path with no scheme is a local directory, as with
file://.Environment variables (
$VARor${VAR}) and a leading~are expanded in any source when it is resolved. A value set in[option,env,...]takes precedence over the process environment.Any scheme takes a
+privatemarker, as ingit+ssh+private://. It says the source must never leave this machine: a remote run does not upload it, so the server has to hold its own copy. A private repository does not need the marker, which is about where the data may go rather than how it is fetched;github+private://andgitlab+private://also skip their anonymous attempt, ands3+private://never sends an unsigned request.A remote source requires a
tagand is fetched once into the dataroot cache, then reused by every project.
Where a remote source reads a token from the environment, every variable it reads
also has a dataroot-specific form, <PREFIX>_<DATAROOT>_TOKEN, which is read
before <PREFIX>_TOKEN. <DATAROOT> is the dataroot’s name in upper case,
with any of # $ & - = ! / . removed: a GitHub dataroot named my-pdk reads
GITHUB_MYPDK_TOKEN before GITHUB_TOKEN. That lets dataroots on one host
use different tokens.
Any of these variables can be stored instead of exported, with
sc-config tokens set, which asks for the token without
echoing it and keeps it in ~/.sc/auth/tokens.json, readable only by you. Each
name is looked up in the environment and then in that store before the next name
is tried. So a stored GITHUB_MYPDK_TOKEN is used ahead of an exported
GITHUB_TOKEN, and only an export of the same name overrides a stored token.
A package can add a scheme of its own through the
siliconcompiler.path_resolver entry point.
7.1. Local sources#
These read data where it already is, and take no tag.
7.1.1. Plain path, file://#
A directory on this machine.
- Schemes:
plain path,
file://,file+private://- Tag:
not used
- Source:
Format
<path> or file://<path>
A relative path is relative to the project’s working directory. Given a
file – most often __file__ – set_dataroot roots the dataroot at
the directory holding it, so a design’s files are found wherever the
script defining it is run from. A path that starts with an environment
variable is how foundry data is referenced without committing its
location.
Example
design.set_dataroot("heartbeat", __file__)
design.set_dataroot("foundry", "$FOUNDRY_ROOT/pdk/v1")
7.1.2. key://#
The directory another schema parameter names.
- Schemes:
key://- Tag:
not used
- Source:
Format
key://<keypath>
<keypath> is a comma-separated keypath from the project, such as
library,<design>,fileset,rtl,idir, and the dataroot is the first path
that parameter holds. A parameter set per node is read for the step and
index being run. The dataroot follows the parameter: change it, and the
files rooted here move with it.
Example
design.set_dataroot("includes", "key://library,mydesign,fileset,rtl,idir")
7.1.3. python://#
A directory inside an installed Python package.
- Schemes:
python://- Tag:
not used
- Source:
Format
python://<module> or python://<module>/<path>
<module> is imported, and stands for the directory holding it – for
a package, the package’s own directory – so the data is found wherever
the package is installed. <path> names a directory inside it; it is
not imported, and need not be a package.
A package whose data does not ship in its wheel can call
PythonPathResolver.set_dataroot instead, which picks python://
for an editable install and a fallback source, typically a git
repository keyed to the package version, for any other.
Example
design.set_dataroot("mylib", "python://mylib/data")
7.1.4. dataroot://#
A directory inside another dataroot.
- Schemes:
dataroot://- Tag:
not used
- Source:
Format
dataroot://<name> or dataroot://<name>/<path>
<name> is another dataroot defined alongside this one, resolved by
its own scheme and tag, and <path> is a directory inside it. One
remote source can then be split into several dataroots while its URL and
tag are written once. A chain of dataroots that leads back to itself is
an error.
Example
design.set_dataroot("pdk", "git+https://github.com/org/pdk.git", tag="v1.0")
design.set_dataroot("pdk-lef", "dataroot://pdk/lef")
7.2. Remote sources#
Fetched once into the dataroot cache and reused by every later run. Each requires a tag, though not every one uses it to choose what is fetched: see its Tag section.
7.2.1. http://, https://#
An archive downloaded over HTTP or HTTPS.
- Schemes:
http://,https://,http+private://,https+private://- Tag:
required
- Cached:
yes, in the dataroot cache
- Source:
Format
https://<host>/<path> or http://<host>/<path>
The download is unpacked into the cache. Its format is read from its contents rather than its name: a tar compressed with gzip, bzip2, xz or Zstandard, or a zip. A URL on a GitHub host is handled as GitHub’s archives are, see GitHub archives over HTTPS.
Tag
Appended to a URL that ends in / as <tag>.tar.gz:
https://example.com/ip/ with the tag v1.0 downloads
https://example.com/ip/v1.0.tar.gz. A URL naming its file outright
uses the tag only to key its cache entry.
Authentication
A username and password in the URL are sent as Basic auth, and a
username alone as Authorization: Bearer <username>. Otherwise the
token is read from HTTPS_TOKEN, then HTTP_TOKEN, and sent as a
Bearer token. A plain http:// URL is never sent a credential, since
it would cross the network in cleartext.
Example
design.set_dataroot("ip", "https://example.com/ip/", tag="v1.0")
7.2.1.1. GitHub archives over HTTPS#
- Schemes:
none of its own; the
http://,https://resolver hands it the URLs below- Tag:
required
- Cached:
yes, in the dataroot cache
- Source:
Format
Any https:// or http:// URL whose host has a github label,
GitHub Enterprise included, such as
https://github.com/<owner>/<repo>/archive/refs/tags/<tag>.tar.gz.
Nothing in the URL marks it: the https:// resolver hands these URLs
here, so a plain GitHub URL gets what GitHub needs without being written
as github://.
A source archive is unwrapped from the <repo>-<version> directory
GitHub packs it in, so the dataroot is the repository’s top level. A
release asset named by its API URL is asked for as the file rather than
as its JSON description.
Tag
As for https://: appended to a URL that ends in / as
<tag>.tar.gz, and otherwise used only to key the cache entry.
Authentication
On github.com and its subdomains the token is read from
GITHUB_TOKEN, GH_TOKEN or GIT_TOKEN, then from the
https:// variables. A GitHub Enterprise host is not GitHub’s, so it
is offered only the https:// variables, never the ambient
GITHUB_TOKEN. Either way the token is sent as
Authorization: Bearer <token>, and a credential in the URL is used
as it is for https://.
Example
design.set_dataroot(
"ip", "https://github.com/org/ip/archive/refs/tags/v1.0.tar.gz",
tag="v1.0")
7.2.2. git://, git+https://, git+ssh://, ssh://#
A Git repository, cloned and checked out at a branch, tag or commit.
- Schemes:
git://,git+https://,git+ssh://,ssh://,git+private://,git+https+private://,git+ssh+private://,ssh+private://- Tag:
required
- Cached:
yes, in the dataroot cache
- Source:
Format
git+https://<host>/<path>, git+ssh://<user>@<host>/<path> or
ssh://<user>@<host>/<path>
git:// is cloned over HTTPS, as git+https:// is. Submodules are
checked out, and Git LFS files fetched, when the repository has them;
?submodules=false or ?lfs=false on the URL skips either. A
repository that uses LFS needs git-lfs installed.
Tag
The branch, tag or commit checked out after cloning.
Authentication
git+ssh:// and ssh:// use this machine’s SSH keys. Prefer them
where you can: they keep the credential out of the URL entirely, while a
token sent over HTTPS is written into the cached clone’s
.git/config.
Over HTTPS the token is read from the environment, or from the stored tokens, and sent as the basic-auth password, under the username the host expects:
Host |
Environment variable |
Sent to the server as |
|---|---|---|
|
|
|
|
|
|
|
|
|
anything else |
|
the username above for a host named after a forge
( |
The username matters: a GitHub App installation token is accepted only in the form above, while a classic personal access token is accepted either way.
A forge’s own variables unlock only for that forge’s own domains. A
self-hosted GitHub Enterprise or GitLab – gitlab.example.com –
still gets the right username, but takes its token from GIT_TOKEN:
a forge name in a host label is not evidence that the forge owns the
host, and GITLAB_TOKEN must not be handed to
gitlab.attacker.example on the strength of one.
For a host that needs some other username, write it into the URL and
the token becomes its password, as in
git+https://<user>@git.example.com/<owner>/<repo>. A password
written into the URL is used as it is.
Example
design.set_dataroot("ip", "git+https://github.com/org/ip.git", tag="v1.0")
7.2.3. github://#
A release asset or source archive from a GitHub repository.
- Schemes:
github://,github+private://- Tag:
required
- Cached:
yes, in the dataroot cache
- Source:
Format
github://<owner>/<repository>/<release>/<asset>
<asset> is an archive attached to the release, found through the
GitHub API and unpacked as its author packed it. An asset named
<release>.tar.gz or <release>.zip is instead the repository’s
source at that tag, unwrapped from the directory GitHub packs it in. An
empty release (.../<repository>//<asset>) means the latest one.
Tag
Required, but it does not choose what is fetched: the release in the URL does. It keys the cache entry along with the URL, so with an empty release in the URL, changing the tag is what fetches the latest one again.
Authentication
The token is read from GITHUB_TOKEN, GH_TOKEN or GIT_TOKEN,
falling back to gh auth token when the GitHub CLI is installed and
logged in, and is sent as Authorization: token <token>. The
repository is looked up anonymously first, and with the token only if
that finds nothing; github+private:// skips the anonymous attempt.
Example
design.set_dataroot("ip", "github://org/ip/v1.0/ip-v1.0.tar.gz", tag="v1.0")
7.2.4. gitlab://#
A release asset or source archive from a GitLab project.
- Schemes:
gitlab://,gitlab+private://- Tag:
required
- Cached:
yes, in the dataroot cache
- Source:
Format
gitlab://<host>/<namespace...>/<project>/<tag>/<asset>
The host is always written out, gitlab.com included. The project may
sit in nested groups (group/subgroup/project): the last two segments
are the tag and the asset, and everything before them is the project’s
path. A tag or asset name holding a / writes it as %2F. An empty
tag (.../<project>//<asset>) means the latest release.
An asset named <tag>.tar.gz, <tag>.tar.bz2 or <tag>.zip is
the project’s source at that tag, downloaded through the API and
unwrapped from the directory GitLab packs it in. Any other name is a
link on the release to an archive, unpacked as its author published it.
Tag
Required, but it does not choose what is fetched: the tag in the URL does. It keys the cache entry along with the URL, so with an empty tag in the URL, changing this one is what fetches the latest release again.
Authentication
A project that cannot be read anonymously is read with a token, sent as
Authorization: Bearer <token> and only ever to the GitLab host
itself. gitlab.com takes GITLAB_TOKEN or GL_TOKEN, then
GIT_TOKEN; a self-hosted instance takes GIT_TOKEN alone, so that
a host which only calls itself GitLab is never handed the ambient
GITLAB_TOKEN. gitlab+private:// skips the anonymous attempt. The
URL cannot carry a credential of its own.
Example
design.set_dataroot("ip", "gitlab://gitlab.com/org/ip/v1.0/v1.0.tar.gz",
tag="v1.0")
7.2.5. s3://#
An archive stored in Amazon S3, or in any store that speaks its API.
- Schemes:
s3://,s3+private://- Tag:
required
- Cached:
yes, in the dataroot cache
- Source:
Format
s3://<bucket>/<key>
The key names one archive object, unpacked into the cache as an
https:// download is: a tar compressed with gzip, bzip2, xz or
Zstandard, or a zip. A ? or # in a key is written %3F or
%23.
A store other than AWS – MinIO, Ceph, Cloudflare R2 and the rest – is
chosen with AWS_ENDPOINT_URL_S3 or AWS_ENDPOINT_URL, not with a
host in the URL. Needs boto3, which comes with the s3 extra:
pip install siliconcompiler[s3].
Tag
Appended to a key that ends in / as <tag>.tar.gz:
s3://bucket/ip/ with the tag v1.0 downloads
s3://bucket/ip/v1.0.tar.gz. A key naming its object outright uses
the tag only to key its cache entry.
Authentication
boto3’s own credential chain, as the AWS CLI reads it: AWS_PROFILE,
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, ~/.aws, SSO, and
an instance or task role. With none found the request is sent unsigned,
which reads a public bucket; s3+private:// requires credentials
instead. The URL cannot carry a credential of its own.
Example
design.set_dataroot("pdk", "s3://bucket/pdks/sky130/", tag="v1.0")
7.2.6. scp://#
A directory copied from another machine with scp.
- Schemes:
scp://,scp+private://- Tag:
required
- Cached:
yes, in the dataroot cache
- Source:
Format
scp://[<user>@]<host>[:<port>]/<path>
<path> is absolute on the remote machine, and the directory there is
copied recursively into the cache. scp has to be on PATH.
Tag
Required, but only keys the cache entry. Once an entry exists it is reused, so a new tag is what copies the directory again.
Authentication
Whatever scp itself uses: this machine’s SSH keys and agent, and
~/.ssh/config. Nothing is read from the environment.
Example
design.set_dataroot("pdk", "scp://user@fileserver/data/pdk", tag="v1.0")