Comments (7)
CC @wendy728 (I have no idea)
from buck2.
Have you tried get_path_without_materialization()
? That should work with the artifact
type. As for the error message about artifact
and artifact
not matching, this is an unfortunate typing issue where the starlark types are the same, but the underlying rust types are different. We would need to do some kind of migration to fix that. Regardless, abs_path_unsafe()
is not the right function here since that's only for source artifacts, not declared or build/output artifacts.
I will add a some docs about that method since people have a hard time finding it in our generated docs, and also work on improving the error message for abs_path_unsafe()
.
As for the restrictions on ensured artifact, yes the API is intentionally restrictive so that people don't accidentally use the paths as strings, which might break in actions ran remotely, for example. See more. here.
from buck2.
I’ll try this. Is there any reason it would be a bad idea for abs_path_unsafe
to work with any kind of artifact?
I think what’s difficult about finding this function is that it doesn’t really make sense as a global. There’s already ctx.fs with similar methods. Or why not just as a member function on the artifact itself? These are the natural places one would expect to find such a method
from buck2.
The functions available on ctx.fs
are for source files/artifacts. So abs_path_unsafe
works with string literals that represent source files, actual source file nodes, or cell paths that are supposed to be source files, and there are no plans to make it work with build artifacts or other types of artifacts.
from buck2.
In that case, how about a method on the artifact object? I tried get_path_without_materializations()
, and it worked perfectly, im just trying to think from an api design standpoint so that more things become self documenting / self discoverable. It's a very unusual and specific function to be a global.
I actually have a local patch that adds this method to output artifact, im just wondering if it’s worth trying to upstream or if it will be seen as making it too easy to do unsafe things.
I understand the desire to make it difficult to shoot yourself in the foot by doing unsafe things, but at the same time one of the primary motivating use cases of bxl (IDE project generation) has heavy reliance on these kinds of unsafe operations.
from buck2.
The issue is that the artifact type is shared between normal rules and BXL. We could probably get it to only be exposed in BXL, but I would have to do some investigation on how to implement it correctly, but also that could be confusing if an object method is only available in BXL vs rules.
from buck2.
Just my own 2c, but I think bxl is a natural place for methods which are really unsafe for rules but quite natural when you want to introspect. IDE project generation, for example, often relies on absolute paths, but you’d never want to use an absolute path in a rule. So bxl should make it easy to get absolute paths for all kinds of things.
from buck2.
Related Issues (20)
- Golden testing? HOT 4
- Watchman/buck2 integration HOT 2
- Why does bxl_actions require an execution platform? HOT 1
- Remote execution can't find executable HOT 13
- haskell_library fails on MacOS
- Feature Request: Shutdown buck2 server after some idle time
- --show-output (and related options show nothing in column 2) when using DefaultInfo with default_outs HOT 1
- Full rebuild after killing daemon HOT 8
- Suggestion: Use tar or zip for release artifacts
- Why can not Buck trigger Buildbarn's g++ using system_cxx_toolchain?
- 'buck2 build //tests:' can not find 'sh' when using case 'buck2/examples/remote_execution/buildbarn/tests'
- License details (for SPDX compliance) HOT 2
- Buck2 performance on single-file update in erlang project HOT 13
- `SRCDIR` is not absolute in genrule script HOT 2
- It should be possible to consume multiple `default_outputs` in an `attrs.list(attrs.source())` HOT 5
- RE: upload cancelled with "stream error: stream no longer needed" HOT 5
- Zig support HOT 2
- Handling environment variables for local and remote builds HOT 2
- How can I check and/or override the path for the linker for rust/cxx? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buck2.