Commit Graph

1493 Commits

Author SHA1 Message Date
Tim 'Piepmatz' Hesse
5542545222 Merge branch 'main' into derive-value 2024-06-06 22:58:25 +02:00
Jakub Žádník
e4104d0792
Span ID Refactor - Step 1 (#12960)
# Description
First part of SpanID refactoring series. This PR adds a `SpanId` type
and a corresponding `span_id` field to `Expression`. Parser creating
expressions will now add them to an array in `StateWorkingSet`,
generates a corresponding ID and saves the ID to the Expression. The IDs
are not used anywhere yet.

For the rough overall plan, see
https://github.com/nushell/nushell/issues/12963.

# User-Facing Changes
Hopefully none. This is only a refactor of Nushell's internals that
shouldn't have visible side effects.

# Tests + Formatting

# After Submitting
2024-06-05 09:57:14 +08:00
Devyn Cairns
28e33587d9
msgpackz: increase default compression level (#13035)
# Description
Increase default compression level for brotli on msgpackz to 3. This has
the best compression time generally. Level 0 and 1 give weird results
and sometimes cause extremely inflated outputs rather than being
compressed. So far this hasn't really been a problem for the plugin
registry file, but has been for other data.

The `$example` is the web-app example from https://json.org/example.html

Benchmarked with:

```nushell
seq 0 11 | each { |level|
  let compressed = ($example | to msgpackz --quality $level)
  let time = (timeit { $example | to msgpackz --quality $level })
  {
    level: $level
    time: $time
    length: ($compressed | bytes length)
    ratio: (($uncompressed_length | into float) / ($compressed | bytes length))
  }
}
```

```
╭────┬───────┬─────────────────┬────────┬───────╮
│  # │ level │      time       │ length │ ratio │
├────┼───────┼─────────────────┼────────┼───────┤
│  0 │     0 │ 4ms 611µs 875ns │   3333 │  0.72 │
│  1 │     1 │ 1ms 334µs 500ns │   3333 │  0.72 │
│  2 │     2 │     190µs 333ns │   1185 │  2.02 │
│  3 │     3 │      184µs 42ns │   1128 │  2.12 │
│  4 │     4 │      245µs 83ns │   1098 │  2.18 │
│  5 │     5 │     265µs 584ns │   1040 │  2.30 │
│  6 │     6 │     270µs 792ns │   1040 │  2.30 │
│  7 │     7 │     444µs 708ns │   1040 │  2.30 │
│  8 │     8 │       1ms 801µs │   1040 │  2.30 │
│  9 │     9 │     843µs 875ns │   1037 │  2.31 │
│ 10 │    10 │ 4ms 128µs 375ns │    984 │  2.43 │
│ 11 │    11 │ 6ms 352µs 834ns │    986 │  2.43 │
╰────┴───────┴─────────────────┴────────┴───────╯
```

cc @maxim-uvarov
2024-06-04 17:19:10 -07:00
Wind
ad5a6cdc00
bump version to 0.94.3 (#13055) 2024-06-05 06:52:40 +08:00
Tim 'Piepmatz' Hesse
f2a1415510 Merge branch 'main' 2024-06-03 16:36:55 +02:00
Devyn Cairns
6635b74d9d
Bump version to 0.94.2 (#13014)
Version bump after 0.94.1 patch release.
2024-06-03 10:28:35 +03:00
Tim 'Piepmatz' Hesse
72533f6a2a removed usize and u64 from test_derive 2024-06-03 00:50:43 +02:00
Tim 'Piepmatz' Hesse
628382283e fmt 2024-06-03 00:50:31 +02:00
Tim 'Piepmatz' Hesse
d7fc6339a2 removed into_value for u64 and usize 2024-06-03 00:39:41 +02:00
Tim 'Piepmatz' Hesse
9c6226184e added docs about derive for macros 2024-06-03 00:37:38 +02:00
Tim 'Piepmatz' Hesse
cc8c620de8 removed call_span from FromValue::from_value 2024-06-03 00:19:57 +02:00
Tim 'Piepmatz' Hesse
1348131387 fixed broken derive test 2024-06-01 23:13:47 +02:00
Tim 'Piepmatz' Hesse
5c30e6c646 applied some clippy fixes in nu-protocol 2024-06-01 23:11:44 +02:00
Tim 'Piepmatz' Hesse
cdc90d553c added remaining enum tests 2024-06-01 21:08:41 +02:00
Tim 'Piepmatz' Hesse
16f85e49ff implemented derive FromValue for enum
still needs fixing tho
2024-06-01 18:22:02 +02:00
Tim 'Piepmatz' Hesse
2b68be5922 typo 2024-06-01 16:15:03 +02:00
Tim 'Piepmatz' Hesse
bdbb0cd088 added error tests for unnamed fields structs 2024-06-01 16:14:57 +02:00
Tim 'Piepmatz' Hesse
8e6bcac5ad cargo fmt 2024-06-01 15:21:18 +02:00
Tim 'Piepmatz' Hesse
887d4cc80b further simplified tests, no more macros 2024-06-01 15:14:47 +02:00
Tim 'Piepmatz' Hesse
ade8c9dbf9 simplified tests with some macros 2024-06-01 11:17:03 +02:00
Tim 'Piepmatz' Hesse
4703fdba47 bumped nu-derive-value version 2024-06-01 09:53:26 +02:00
Tim 'Piepmatz' Hesse
748b3c39af Merge branch 'main' 2024-06-01 09:48:54 +02:00
Tim 'Piepmatz' Hesse
ce24586026 added a few more tests 2024-05-30 09:40:25 +02:00
Tim 'Piepmatz' Hesse
51b1606b54 implemented FromValue for Hashmaps 2024-05-30 09:40:15 +02:00
Devyn Cairns
f3991f2080
Bump version to 0.94.1 (#12988)
Merge this PR before merging any other PRs.
2024-05-28 22:41:23 +00:00
Jakub Žádník
61182deb96
Bump version to 0.94.0 (#12987) 2024-05-28 12:04:09 -07:00
Tim 'Piepmatz' Hesse
da3a60720c updated derive test to also include FromValue for Primitives 2024-05-27 09:43:40 +02:00
Tim 'Piepmatz' Hesse
1294f3947f implemented FromValue for unit and tuples 2024-05-27 09:43:15 +02:00
Tim 'Piepmatz' Hesse
a517042e6d updated docs on FromValue::expected_type 2024-05-27 09:42:59 +02:00
Tim 'Piepmatz' Hesse
3d40a4a0c5 fixed IntoValue tuple macro not working for n=1 tuples 2024-05-27 08:52:48 +02:00
Tim 'Piepmatz' Hesse
998a04efdd removed IntoValue for str as the inverse isn't feasible 2024-05-27 08:52:16 +02:00
Ian Manske
6012af2412
Fix panic when redirecting nothing (#12970)
# Description
Fixes #12969 where the parser can panic if a redirection is applied to
nothing / an empty command.

# Tests + Formatting
Added a test.
2024-05-27 10:03:06 +08:00
Tim 'Piepmatz' Hesse
315e99aadd added call_span to FromValue::from_value 2024-05-26 12:10:26 +02:00
Tim 'Piepmatz' Hesse
95ad0b0aa4 use real sentences 2024-05-25 08:46:05 +02:00
Tim 'Piepmatz' Hesse
5b1df81580 added missing expected_type impl for i8, i16 and i32 2024-05-25 08:29:20 +02:00
Tim 'Piepmatz' Hesse
92fc985d6d implemented FromValue for a lot of primitives 2024-05-25 08:26:08 +02:00
Ian Manske
c5d716951f
Allow byte streams with unknown type to be compatiable with binary (#12959)
# Description
Currently, this pipeline doesn't work `open --raw file | take 100`,
since the type of the byte stream is `Unknown`, but `take` expects
`Binary` streams. This PR changes commands that expect
`ByteStreamType::Binary` to also work with `ByteStreamType::Unknown`.
This was done by adding two new methods to `ByteStreamType`:
`is_binary_coercible` and `is_string_coercible`. These return true if
the type is `Unknown` or matches the type in the method name.
2024-05-24 17:54:38 -07:00
Devyn Cairns
b06f31d3c6
Make from json --objects streaming (#12949)
# Description

Makes the `from json --objects` command produce a stream, and read
lazily from an input stream to produce its output.

Also added a helper, `PipelineData::get_type()`, to make it easier to
construct a wrong type error message when matching on `PipelineData`. I
expect checking `PipelineData` for either a string value or an `Unknown`
or `String` typed `ByteStream` will be very, very common. I would have
liked to have a helper that just returns a readable stream from either,
but that would either be a bespoke enum or a `Box<dyn BufRead>`, which
feels like it wouldn't be so great for performance. So instead, taking
the approach I did here is probably better - having a function that
accepts the `impl BufRead` and matching to use it.

# User-Facing Changes

- `from json --objects` no longer collects its input, and can be used
for large datasets or streams that produce values over time.

# Tests + Formatting
All passing.

# After Submitting
- [ ] release notes

---------

Co-authored-by: Ian Manske <ian.manske@pm.me>
2024-05-24 23:37:50 +00:00
Darren Schroeder
7d11c28eea
Revert "Remove std::env::set_current_dir() call from EngineState::merge_env()" (#12954)
Reverts nushell/nushell#12922
2024-05-24 11:09:59 -05:00
Tim 'Piepmatz' Hesse
2d3be849d5 sorted and grouped impls 2024-05-23 16:13:24 +02:00
Tim 'Piepmatz' Hesse
ea8556ca9b streamlined FromValue impls 2024-05-23 15:13:20 +02:00
Tim 'Piepmatz' Hesse
79930a82d8 updated some docs and formatted 2024-05-23 15:12:34 +02:00
Tim 'Piepmatz' Hesse
5965fbc93c replace manual FromValue impls for Spanned with a blanket impl 2024-05-23 12:17:44 +02:00
Jakub Žádník
64afb52ffa
Fix leftover wrong column name (#12937)
# Description

Small fixup for https://github.com/nushell/nushell/pull/12930
2024-05-22 21:24:22 +00:00
YizhePKU
7ede90cba5
Remove std::env::set_current_dir() call from EngineState::merge_env() (#12922)
As discussed in https://github.com/nushell/nushell/pull/12749, we no
longer need to call `std::env::set_current_dir()` to sync `$env.PWD`
with the actual working directory. This PR removes the call from
`EngineState::merge_env()`.
2024-05-22 19:58:27 +03:00
Jakub Žádník
75689ec98a
Small improvements to debug profile (#12930)
<!--
if this PR closes one or more issues, you can automatically link the PR
with
them by using one of the [*linking
keywords*](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword),
e.g.
- this PR should close #xxxx
- fixes #xxxx

you can also mention related issues, PRs or discussions!
-->

# Description
<!--
Thank you for improving Nushell. Please, check our [contributing
guide](../CONTRIBUTING.md) and talk to the core team before making major
changes.

Description of your pull request goes here. **Provide examples and/or
screenshots** if your changes affect the user experience.
-->

1. With the `-l` flag, `debug profile` now collects files and line
numbers of profiled pipeline elements

![profiler_lines](https://github.com/nushell/nushell/assets/25571562/b400a956-d958-4aff-aa4c-7e65da3f78fa)

2. Error from the profiled closure will be reported instead of silently
ignored.

![profiler_lines_error](https://github.com/nushell/nushell/assets/25571562/54f7ad7a-06a3-4d56-92c2-c3466917bee8)


# User-Facing Changes
<!-- List of all changes that impact the user experience here. This
helps us keep track of breaking changes. -->

New `--lines(-l)` flag to `debug profile`. The command will also fail if
the profiled closure fails, so technically it is a breaking change.

# Tests + Formatting
<!--
Don't forget to add tests that cover your changes.

Make sure you've run and fixed any issues with these commands:

- `cargo fmt --all -- --check` to check standard code formatting (`cargo
fmt --all` applies these changes)
- `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used` to
check that you're using the standard code style
- `cargo test --workspace` to check that all tests pass (on Windows make
sure to [enable developer
mode](https://learn.microsoft.com/en-us/windows/apps/get-started/developer-mode-features-and-debugging))
- `cargo run -- -c "use toolkit.nu; toolkit test stdlib"` to run the
tests for the standard library

> **Note**
> from `nushell` you can also use the `toolkit` as follows
> ```bash
> use toolkit.nu # or use an `env_change` hook to activate it
automatically
> toolkit check pr
> ```
-->

# After Submitting
<!-- If your PR had any user-facing changes, update [the
documentation](https://github.com/nushell/nushell.github.io) after the
PR is merged, if necessary. This will help us keep the docs up to date.
-->

---------

Co-authored-by: Ian Manske <ian.manske@pm.me>
2024-05-22 19:56:51 +03:00
Tim 'Piepmatz' Hesse
8689ace208 use type and content instead of $type and $content 2024-05-22 16:42:19 +02:00
Tim 'Piepmatz' Hesse
1fbc2f1181 implemented and tested into value for Hashmap 2024-05-22 15:03:05 +02:00
Tim 'Piepmatz' Hesse
78343ef7a9 added a test for deriving enums 2024-05-22 11:37:39 +02:00
Tim 'Piepmatz' Hesse
d1fd69b1f8 added a test for a derive unit struct 2024-05-22 11:24:27 +02:00