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

Replace explicit features and paths on generated code #886

Merged
merged 4 commits into from
Dec 2, 2023

Conversation

swfsql
Copy link
Contributor

@swfsql swfsql commented Nov 8, 2023

Closes #885 .

  • Disallow feature detection on generated code.
    • Move feature detection to before generating code.
    • Only emits the SaveSafeTensors and LoadSafeTensors derivations (as in, injecting the derivation command, not the final derivation itself) and the #[serialize] attr if the dfdx/safetensors feature is enabled.
    • Add dfdx-derives/safetensors feature.
    • Users apps no longer need to have a safetensors feature directly.
  • Only use ::dfdx as a path entrypoint on code generation
    • Re-export the self crate as dfdx.
    • Change the generated code so they always have the ::dfdx path entrypoint.
      • User apps no longer need to depend on dfdx-core nor dfdx-derives directly.
    • Re-export safetensors lib.
      • User apps no longer need to depend on safetensors directly (as in, this is no longer required by the SaveSafeTensors and LoadSafeTensors derivations).

- Move feature detection to before generating code.
- Only emits the `SaveSafeTensors` and `LoadSafeTensors` derivations and the `#[serialize]` attr if the `safetensors` feature is enabled.
- Re-export the `self` crate as `dfdx`.
  - See [related question](https://users.rust-lang.org/t/how-to-express-crate-path-in-procedural-macros/91274/10).
  - Does the same for `dfdx-core`.
- Change the generated code so they always have the `::dfdx` path entrypoint.
  - User apps no longer need to depend on `dfdx-core` or `dfdx-derives` directly.
- Re-export `safetensors`.
  - User apps no longer need to depend on `safetensors` directly (as in, this is no longer required by the `SaveSafeTensors` and `LoadSafeTensors` derivations).
@swfsql swfsql changed the title Disallow feature detection on generated code; Only use ::dfdx as a path entrypoint on code generation Replace explicit features and paths on generated code Nov 8, 2023
@swfsql swfsql marked this pull request as ready for review November 8, 2023 04:19
Copy link
Owner

@coreylowman coreylowman left a comment

Choose a reason for hiding this comment

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

Nice changes, thanks for this!

@coreylowman coreylowman merged commit a522c7a into coreylowman:main Dec 2, 2023
4 checks passed
@swfsql swfsql deleted the issue-885 branch March 1, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace explicit features and paths on generated code
2 participants