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

fix: alias depends_on to depends-on #1310

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/examples/cpp-sdl.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Run the `start` command
pixi run start
```

Using the [`depends_on`](../features/advanced_tasks.md#depends-on) feature you only needed to run the `start` task but under water it is running the following tasks.
Using the [`depends-on`](../features/advanced_tasks.md#depends-on) feature you only needed to run the `start` task but under water it is running the following tasks.

```shell
# Configure the CMake project
Expand Down
8 changes: 4 additions & 4 deletions docs/features/advanced_tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ configure = { cmd = [
] }

# Depend on other tasks
build = { cmd = ["ninja", "-C", ".build"], depends_on = ["configure"] }
build = { cmd = ["ninja", "-C", ".build"], depends-on = ["configure"] }

# Using environment variables
run = "python main.py $PIXI_PROJECT_ROOT"
Expand Down Expand Up @@ -62,9 +62,9 @@ Results in the following lines added to the `pixi.toml`
# Configures CMake
configure = "cmake -G Ninja -S . -B .build"
# Build the executable but make sure CMake is configured first.
build = { cmd = "ninja -C .build", depends_on = ["configure"] }
build = { cmd = "ninja -C .build", depends-on = ["configure"] }
# Start the built executable
start = { cmd = ".build/bin/sdl_example", depends_on = ["build"] }
start = { cmd = ".build/bin/sdl_example", depends-on = ["build"] }
```

```shell
Expand Down Expand Up @@ -95,7 +95,7 @@ Results in the following `pixi.toml`.
```toml title="pixi.toml"
fmt = "ruff"
lint = "pylint"
style = { depends_on = ["fmt", "lint"] }
style = { depends-on = ["fmt", "lint"] }
```

Now run both tools with one command.
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ pixi run --environment cuda python
This is done so that the run commands can be run across all platforms.

!!! tip "Cross environment tasks"
If you're using the `depends_on` feature of the `tasks`, the tasks will be run in the order you specified them.
The `depends_on` can be used cross environment, e.g. you have this `pixi.toml`:
If you're using the `depends-on` feature of the `tasks`, the tasks will be run in the order you specified them.
The `depends-on` can be used cross environment, e.g. you have this `pixi.toml`:
??? "pixi.toml"
```toml
[tasks]
start = { cmd = "python start.py", depends_on = ["build"] }
start = { cmd = "python start.py", depends-on = ["build"] }

[feature.build.tasks]
build = "cargo build"
Expand Down Expand Up @@ -248,7 +248,7 @@ This adds the following to the [manifest file](configuration.md):
[tasks]
cow = "cowpy \"Hello User\""
tls = { cmd = "ls", cwd = "tests" }
test = { cmd = "cargo t", depends_on = ["build"] }
test = { cmd = "cargo t", depends-on = ["build"] }

[target.osx-64.tasks]
build-osx = "METAL=1 cargo build"
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ Pixi's tasks are run in a pixi environment using `pixi run` and are executed usi
[tasks]
simple = "echo This is a simple task"
cmd = { cmd="echo Same as a simple task but now more verbose"}
depending = { cmd="echo run after simple", depends_on="simple"}
alias = { depends_on=["depending"]}
depending = { cmd="echo run after simple", depends-on="simple"}
alias = { depends-on=["depending"]}
download = { cmd="curl -o file.txt https://example.com/file.txt" , outputs=["file.txt"]}
build = { cmd="npm build", cwd="frontend", inputs=["frontend/package.json", "frontend/*.js"]}
run = { cmd="python run.py $ARGUMENT", env={ ARGUMENT="value" }}
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/ros2.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ pixi run hello
???+ tip "Advanced task usage"
Tasks are a powerful feature in pixi.

- You can add [`depends_on`](../features/advanced_tasks.md#depends-on) to the tasks to create a task chain.
- You can add [`depends-on`](../features/advanced_tasks.md#depends-on) to the tasks to create a task chain.
- You can add [`cwd`](../features/advanced_tasks.md#working-directory) to the tasks to run the task in a different directory from the root of the project.
- You can add [`inputs` and `outputs`](../features/advanced_tasks.md#caching) to the tasks to create a task that only runs when the inputs are changed.
- You can use the [`target`](../reference/configuration.md#the-target-table) syntax to run specific tasks on specific machines.
Expand All @@ -177,7 +177,7 @@ pixi run hello
[tasks]
sim = "ros2 run turtlesim turtlesim_node"
build = {cmd = "colcon build --symlink-install", inputs = ["src"]}
hello = { cmd = "ros2 run my_package my_node", depends_on = ["build"] }
hello = { cmd = "ros2 run my_package my_node", depends-on = ["build"] }
```

## Build a C++ node
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ You can add a formatting task to your project:
pixi task add fmt "cargo fmt"
```

You can extend these tasks to run multiple commands with the use of the `depends_on` field.
You can extend these tasks to run multiple commands with the use of the `depends-on` field.
```shell
pixi task add lint "cargo clippy" --depends-on fmt
```
Expand Down
4 changes: 2 additions & 2 deletions examples/cpp-sdl/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"]
[tasks.start]
# Start the built executable
cmd = ".build/bin/sdl_example"
depends_on = ["build"]
depends-on = ["build"]

[dependencies]
sdl2 = "2.26.5.*"
Expand All @@ -36,7 +36,7 @@ outputs = [".build/CMakeFiles/"]
# Build the executable but make sure CMake is configured first.
[feature.build.tasks.build]
cmd = ["cmake", "--build", ".build"]
depends_on = ["configure"]
depends-on = ["configure"]
inputs = ["CMakeLists.txt", "src/*"]
outputs = [".build/bin/sdl_example"]

Expand Down
2 changes: 1 addition & 1 deletion examples/ctypes-factorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This examples calculates approximate factorials of large numbers using pure Pyth
## Features demonstrated:
- packaging C and Python libraries together
- compiling with gcc through Pixi tasks
- conditional Pixi task execution (`depends_on`)
- conditional Pixi task execution (`depends-on`)
- defining tasks with arguments


Expand Down
2 changes: 1 addition & 1 deletion examples/ctypes-factorial/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ start = { cmd = [
"12345678",
"-e",
"python",
], depends_on = "compile" }
], depends-on = "compile" }

[target.osx-64.tasks]
compile = { cmd = "clang -shared -o src/factorial.so src/factorial.c" }
Expand Down
2 changes: 1 addition & 1 deletion examples/multi-machine/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"]
[tasks]
train = "python train.py"
test = "python test.py"
start = { depends_on = ["train", "test"] }
start = { depends-on = ["train", "test"] }

[dependencies]
python = "3.11.*"
Expand Down
2 changes: 1 addition & 1 deletion examples/qgis/pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ platforms = ["linux-64", "win-64", "osx-64", "osx-arm64"]

[tasks]
get-data = "python get_data.py"
start = { cmd = "qgis earthquakes_example.qgz", depends_on = "get-data" }
start = { cmd = "qgis earthquakes_example.qgz", depends-on = "get-data" }

[dependencies]
qgis = "3.32.1.*"
Expand Down
1 change: 1 addition & 0 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ deploy-dev = "mike deploy --push dev devel"

[feature.schema.tasks]
generate-schema = { cmd = "python model.py > schema.json", cwd = "schema" }
# Using deprecated `depends_on` to avoid conflicts in ci. Changes after release.
test-schema = { cmd = "pytest -s", depends_on = "generate-schema", cwd = "schema" }
toml-lint = "taplo lint --verbose **/pixi.toml"
toml-format = "taplo fmt **/pixi.toml"
Expand Down
17 changes: 9 additions & 8 deletions schema/examples/valid/full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ package1 = { version = ">=1.2.3", build="py34_0" }

[tasks]
build = "conda build ."
# deprecated depends_on
test = { cmd = "pytest", cwd = "tests", depends_on = ["build"] }
test2 = { cmd = "pytest", cwd = "tests"}
test3 = { cmd = "pytest", depends_on = ["test2"] }
test4 = { cmd = "pytest", cwd = "tests", depends_on = ["test2"] }
test3 = { cmd = "pytest", depends-on = ["test2"] }
test4 = { cmd = "pytest", cwd = "tests", depends-on = ["test2"] }
test5 = { cmd = "pytest" }
test6 = { depends_on = ["test5"] }
test7 = { cmd = "pytest", cwd = "tests", depends_on = ["test5"], env = {PYTHONPATH = "bla", "WEIRD_STRING" = "blu"}}
test6 = { depends-on = ["test5"] }
test7 = { cmd = "pytest", cwd = "tests", depends-on = ["test5"], env = {PYTHONPATH = "bla", "WEIRD_STRING" = "blu"}}

[system-requirements]
linux = "5.10"
Expand Down Expand Up @@ -102,12 +103,12 @@ package1 = { version = ">=1.2.3", build="py34_0" }

[target.linux-64.tasks]
build = "conda build ."
test = { cmd = "pytest", cwd = "tests", depends_on = ["build"] }
test = { cmd = "pytest", cwd = "tests", depends-on = ["build"] }
test2 = { cmd = "pytest", cwd = "tests"}
test3 = { cmd = "pytest", depends_on = ["test2"] }
test4 = { cmd = "pytest", cwd = "tests", depends_on = ["test2"] }
test3 = { cmd = "pytest", depends-on = ["test2"] }
test4 = { cmd = "pytest", cwd = "tests", depends-on = ["test2"] }
test5 = { cmd = "pytest" }
test6 = { depends_on = ["test5"] }
test6 = { depends-on = ["test5"] }

[feature.test.target.linux-64.dependencies]
test = "*"
Expand Down
7 changes: 7 additions & 0 deletions schema/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,15 @@ class TaskInlineTable(StrictBaseModel):
description="A shell command to run the task in the limited, but cross-platform `bash`-like `deno_task_shell`. See the documentation for [supported syntax](https://pixi.sh/latest/features/advanced_tasks/#syntax)",
)
cwd: PathNoBackslash | None = Field(None, description="The working directory to run the task")
# BREAK: `depends_on` is deprecated, use `depends-on`
depends_on_deprecated: list[TaskName] | TaskName | None = Field(
None,
alias = "depends_on",
description="The tasks that this task depends on. Environment variables will **not** be expanded. Deprecated in favor of `depends-on` from v0.21.0 onward.",
)
depends_on: list[TaskName] | TaskName | None = Field(
None,
alias="depends-on",
description="The tasks that this task depends on. Environment variables will **not** be expanded.",
)
inputs: list[Glob] | None = Field(
Expand Down
21 changes: 20 additions & 1 deletion schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1042,9 +1042,28 @@
"type": "string",
"pattern": "^[^\\\\]+$"
},
"depends-on": {
"title": "Depends-On",
"description": "The tasks that this task depends on. Environment variables will **not** be expanded.",
"anyOf": [
{
"type": "array",
"items": {
"description": "A valid task name.",
"type": "string",
"pattern": "^[^\\s\\$]+$"
}
},
{
"description": "A valid task name.",
"type": "string",
"pattern": "^[^\\s\\$]+$"
}
]
},
"depends_on": {
"title": "Depends On",
"description": "The tasks that this task depends on. Environment variables will **not** be expanded.",
"description": "The tasks that this task depends on. Environment variables will **not** be expanded. Deprecated in favor of `depends-on` from v0.21.0 onward.",
"anyOf": [
{
"type": "array",
Expand Down
4 changes: 2 additions & 2 deletions src/cli/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ impl From<Task> for Item {
}
if !process.depends_on.is_empty() {
table.insert(
"depends_on",
"depends-on",
Value::Array(Array::from_iter(
process
.depends_on
Expand All @@ -339,7 +339,7 @@ impl From<Task> for Item {
Task::Alias(alias) => {
let mut table = Table::new().into_inline_table();
table.insert(
"depends_on",
"depends-on",
Value::Array(Array::from_iter(
alias
.depends_on
Expand Down
12 changes: 6 additions & 6 deletions src/project/manifest/pyproject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ mod tests {

[tool.pixi.tasks]
build = "conda build ."
test = { cmd = "pytest", cwd = "tests", depends_on = ["build"] }
test = { cmd = "pytest", cwd = "tests", depends-on = ["build"] }
test2 = { cmd = "pytest", cwd = "tests"}
test3 = { cmd = "pytest", depends_on = ["test2"] }
test3 = { cmd = "pytest", depends-on = ["test2"] }
test5 = { cmd = "pytest" }
test6 = { depends_on = ["test5"] }
test6 = { depends-on = ["test5"] }

[tool.pixi.system-requirements]
linux = "5.10"
Expand Down Expand Up @@ -333,11 +333,11 @@ mod tests {

[tool.pixi.target.linux-64.tasks]
build = "conda build ."
test = { cmd = "pytest", cwd = "tests", depends_on = ["build"] }
test = { cmd = "pytest", cwd = "tests", depends-on = ["build"] }
test2 = { cmd = "pytest", cwd = "tests"}
test3 = { cmd = "pytest", depends_on = ["test2"] }
test3 = { cmd = "pytest", depends-on = ["test2"] }
test5 = { cmd = "pytest" }
test6 = { depends_on = ["test5"] }
test6 = { depends-on = ["test5"] }

[tool.pixi.feature.test.target.linux-64.dependencies]
test = "bla"
Expand Down
8 changes: 5 additions & 3 deletions src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ pub struct Execute {
pub outputs: Option<Vec<String>>,

/// A list of commands that should be run before this one
#[serde(default)]
// BREAK: Make the alias a renamed field to force kebab-case
#[serde(default, alias = "depends-on")]
#[serde_as(deserialize_as = "OneOrMany<_, PreferMany>")]
pub depends_on: Vec<TaskName>,

Expand Down Expand Up @@ -247,6 +248,7 @@ impl CmdArgs {
#[serde_as]
pub struct Alias {
/// A list of commands that should be run before this one
#[serde(alias = "depends-on")]
#[serde_as(deserialize_as = "OneOrMany<_, PreferMany>")]
pub depends_on: Vec<TaskName>,
}
Expand All @@ -269,13 +271,13 @@ impl Display for Task {
if depends_on.len() == 1 {
write!(
f,
", depends_on = '{}'",
", depends-on = '{}'",
depends_on.iter().map(|t| t.fancy_display()).join(",")
)?;
} else {
write!(
f,
", depends_on = [{}]",
", depends-on = [{}]",
depends_on.iter().map(|t| t.fancy_display()).join(",")
)?;
}
Expand Down
Loading
Loading