Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Platform V1 Spec #1187

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Add Platform V1 Spec #1187

wants to merge 10 commits into from

Conversation

rydrman
Copy link
Collaborator

@rydrman rydrman commented Mar 7, 2025

The next stage in work for #1121 which adds a new way to specify platforms with static build version as well as separated build and runtime requests.

Here is the updated doc page for reference, note that there is no information about the static build version yet as it's not used by anything:


Specifying Platforms

As a concept, platforms are packages that only provide opinions on what should exist in an environment. They contain no files or code, and have no concrete dependencies but limit what versions are allowed in order to enforce consistency across teams, applications and developers.

As an example, the VFX Reference Platform provides "a set of tools and library version to be used as a common target platform for building software for the VFX industry". Platforms in SPK were designed to be able to describe and enforce these kind of recommendations.

Platforms are Packages

At their core, platforms are a convent way to write package specs that only provide an opinion on what versions can be used and nothing else. Once defines, platforms are still built, published, and used the same way as any other package.

A platform spec reduces the amount of boilerplate needed to set up a platform package compared to using the full v0/package recipe format. A platform spec will be filled in with appropriate defaults automatically for a platform-style package.

Creating Platforms

Below is an example platform

api: v1/platform
platform: company-platform/2025.01.01
requirements:
  - pkg: gcc
    atBuild: =9.3.1
    atRuntime: 9.3.1
  - pkg: python
    atBuild: =3.9.18
    atRuntime: 3.9
  - pkg: imath
    atBuild: =3.0.1
    atRuntime: 3

The platform: fields provides the name of the platform package. The
api: field indicates this is a platform spec.

The requirements field contains the list of requirements in the
platform. In each case, the requirement specifies the version request to be
used at build time vs at run time. This allows the platform to differently
constrain the requirement depending on if it's being used to define a build
environment or a runtime environment.

These requirements are placed onto the build and run components of the package
generated by this platform, respectively. The generated requirements will have
include: IfAlreadyPresent added to them automatically, it does not need to be
specified for them.

Inheritance

Additionally, the platform spec provides a way to inherit requirements from another package. Typically, it makes the most sense to inherit from another platform, but it could be any package.

By inheriting from base packages, platforms can augment and override their requirements. For example, a DCC (Digital Concent Creation) application platform can inherit the requirements from company or site-specific platform and then introduce additional constraints for the application itself.

Here is an example platform spec that inherits from the 'company-platform' and makes adjustments of its own:

api: v1/platform
platform: dcc-platform/2025.01.01
base:
  - company-platform/2024.01.01
requirements:
  # this DCC uses an older version of python
  - pkg: python
    atBuild: =3.7.10
    atRuntime: 3.7
  # it also has no need to constrain the version of imath that's used
  - pkg: imath
    atBuild: false
    atRuntime: false

The base: field indicates which platform this one inherits from. In the case of multiple bases, each one simply overrides the previous in turn.

Any atBuild or atRuntime value that is specified in the platform spec will override the same value for the named requirement in the bases. Conversely, this also means that if a requirement omits either of the atBuild or atRuntime fields, then the value from the base will still remain.

The special false value can be used to remove the requirement entirely.

This is the complete specification of the same resulting dcc-platform without basing it on the company-platform:

api: v1/platform
platform: dcc-platform
requirements:
  - pkg: gcc
    atBuild: =9.3.1
    atRuntime: 9.3.1
  - pkg: python
    atBuild: =3.7.10
    atRuntime: 3.7
  # - pkg: imath not present

@rydrman rydrman added the enhancement New feature or request label Mar 7, 2025
@rydrman rydrman requested review from jrray and dcookspi March 7, 2025 19:21
@rydrman rydrman self-assigned this Mar 7, 2025
@rydrman rydrman force-pushed the workspaces3 branch 2 times, most recently from b24fa83 to 6d9277b Compare March 7, 2025 19:28
Base automatically changed from rust-edition-2024 to main March 8, 2025 01:59
@rydrman
Copy link
Collaborator Author

rydrman commented Mar 12, 2025

From the meeting today:

  • reference docs for v0 platform and v1 platform (like we do for spec)


As a concept, platforms are packages that only provide _opinions_ on what should exist in an environment. They contain no files or code, and have no concrete dependencies but limit what versions are allowed in order to enforce consistency across teams, applications and developers.

As an example, the [VFX Reference Platform](https://vfxplatform.com/) provides "a set of tools and library version to be used as a common target platform for building software for the VFX industry". Platforms in SPK were designed to be able to describe and enforce these kind of recommendations.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
As an example, the [VFX Reference Platform](https://vfxplatform.com/) provides "a set of tools and library version to be used as a common target platform for building software for the VFX industry". Platforms in SPK were designed to be able to describe and enforce these kind of recommendations.
As an example, the [VFX Reference Platform](https://vfxplatform.com/) provides "a set of tools and library versions to be used as a common target platform for building software for the VFX industry". Platforms in SPK were designed to be able to describe and enforce these kinds of recommendations.


### Platforms are Packages

At their core, platforms are a convent way to write package specs that only provide an opinion on what versions can be used and nothing else. Once defines, platforms are still built, published, and used the same way as any other package.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
At their core, platforms are a convent way to write package specs that only provide an opinion on what versions can be used and nothing else. Once defines, platforms are still built, published, and used the same way as any other package.
At their core, platforms are a convenient way to write package specs that only provide an opinion on what versions can be used and nothing else. Once defined, platforms are still built, published, and used the same way as any other package.

atRuntime: 3
```

The `platform:` fields provides the name of the platform package. The
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
The `platform:` fields provides the name of the platform package. The
The `platform:` field provides the name of the platform package. The


Additionally, the platform spec provides a way to inherit requirements from another package. Typically, it makes the most sense to inherit from another platform, but it could be any package.

By inheriting from base packages, platforms can augment and override their requirements. For example, a DCC (Digital Concent Creation) application platform can inherit the requirements from company or site-specific platform and then introduce additional constraints for the application itself.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
By inheriting from base packages, platforms can augment and override their requirements. For example, a DCC (Digital Concent Creation) application platform can inherit the requirements from company or site-specific platform and then introduce additional constraints for the application itself.
By inheriting from base packages, platforms can augment and override their requirements. For example, a DCC (Digital Content Creation) application platform can inherit the requirements from company or site-specific platforms and then introduce additional constraints for the application itself.

- pkg: python
atBuild: =3.7.10
atRuntime: 3.7
# it also has no need to constrain the version of imath that's used
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# it also has no need to constrain the version of imath that's used
# it also has no need to constrain the version of imath that is used

Comment on lines +196 to +199
/// Return the canonical name of this request.
pub fn name(&self) -> &OptName {
spk_schema_foundation::spec_ops::Named::name(self)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to keep this?

self.iter().find(|c| name == c.name)
}

/// Retrieve a component with the provided name or build an insert new one
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Retrieve a component with the provided name or build an insert new one
/// Retrieve a component with the provided name or insert a new one

}

/// Get a mutable reference to the first request with the given name
pub fn get_mut(&mut self, name: impl AsRef<str>) -> Option<&mut R> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This allows the caller to violate the unique name invariant by changing the name of item returned.

Comment on lines +91 to +92
/// All requests with the same name as the given name are removed
/// from the list.
Copy link
Collaborator

Choose a reason for hiding this comment

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

No arguments about the implementation here but there is an invariant that names can't be repeated, so the way this is worded is a bit misleading since it implies it could be normal for there to be multiples.

I recognize that this is an existing docstring that is just being relocated.

Comment on lines +294 to +295
- pkg: inherit-me2
atRuntime: false
Copy link
Collaborator

Choose a reason for hiding this comment

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

           - pkg: inherit-me2
             atBuild: =1.0.0
             atRuntime: false

What would happen if I wrote this?

Will it be legal to say a package is required [to be a specific version] for build environments but have no influence on runtime environments?

I'm not necessarily arguing for that to be a feature, but looking at this test behavior it is treating this as deleting inherit-me2 from the list. Would the same happen if this said atBuild: false instead of atRuntime: false?

If it is not possible to mix and match false and not-false then I would suggest a different way of expressing deletes, like we have in v0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants