Commit Graph

505 Commits

Author SHA1 Message Date
Denis Bilenko (aider) 9bd6229844 refactor: Improve error handling and prevent potential panics in wheel parsing 2025-03-04 11:52:45 +01:00
Denis Bilenko (aider) 6b5fa7ad33 fix: Correct variable assignment in patchwheel seeker reset 2025-03-04 11:51:04 +01:00
Denis Bilenko (aider) 7e747d29ac refactor: Simplify zip file reader seeking by removing unnecessary fallback logic 2025-03-04 11:50:12 +01:00
Denis Bilenko (aider) 80617cbb02 fix: Update patchRecord function to accept io.Reader instead of []byte 2025-03-04 11:48:08 +01:00
Denis Bilenko (aider) bbe90007d8 refactor: Optimize wheel patching by using io.Reader directly 2025-03-04 11:46:08 +01:00
Denis Bilenko 58e746757d clean up redundant comments 2025-03-04 11:37:18 +01:00
Denis Bilenko d54d093ecf do not return error from readMetadataAndRecord; make parse() work only on filenames (without path) 2025-03-04 11:34:45 +01:00
Denis Bilenko 6a7fae08ba clean up redundant comments 2025-03-04 11:21:16 +01:00
Denis Bilenko ba3062b654 rm copy 2025-03-04 10:01:45 +01:00
Denis Bilenko cc5133a5e4 clean up 2025-03-04 09:59:55 +01:00
Denis Bilenko 0aec26705f clean up 2025-03-03 21:31:58 +01:00
Denis Bilenko (aider) efa924613a refactor: Extract version verification into reusable function in patch_test.go 2025-03-03 21:14:01 +01:00
Denis Bilenko 1045dc169b refactor: Improve version verification comments in patch test 2025-03-03 21:13:59 +01:00
Denis Bilenko 84f4b5cd78 test: Add TODO comments for version verification in patch test 2025-03-03 21:12:38 +01:00
Denis Bilenko (aider) fc48cff153 fix: Implement atomic file write with temporary file in PatchWheel 2025-03-03 21:10:11 +01:00
Denis Bilenko 4afaf98324 refactor: Improve wheel patching with TODO comment and minor code cleanup 2025-03-03 21:10:08 +01:00
Denis Bilenko bc1b339f6a rename patchwheel to patch.go 2025-03-03 21:01:26 +01:00
Denis Bilenko c3b659c5e3 extract parse.go 2025-03-03 21:00:50 +01:00
Denis Bilenko (aider) 97109ec438 test: Modify writeProjectFiles to handle errors internally in tests 2025-03-03 20:58:28 +01:00
Denis Bilenko ea5690eb67 refactor: Remove commented-out code and improve test setup comment 2025-03-03 20:58:27 +01:00
Denis Bilenko 5689d6f7c2 formatting & clean up 2025-03-03 20:53:43 +01:00
Denis Bilenko (aider) 613d38d79d fix: Validate wheel metadata version and distribution against filename 2025-03-03 20:50:46 +01:00
Denis Bilenko (aider) 19b330be01 fix: Resolve variable redeclaration issues in PatchWheel function 2025-03-03 20:49:25 +01:00
Denis Bilenko (aider) f5530d9ed4 feat: Enhance wheel filename parsing and add target wheel existence check 2025-03-03 20:48:37 +01:00
Denis Bilenko 43be8ea727 refactor: Simplify wheel filename parsing and remove unused imports 2025-03-03 20:45:53 +01:00
Denis Bilenko (aider) a7e10066ca feat: Add idempotency to PatchWheel and extract version from wheel filename 2025-03-03 20:42:22 +01:00
Denis Bilenko (aider) 8d041437c7 refactor: Replace deprecated SetModTime with Modified field 2025-03-03 20:38:17 +01:00
Denis Bilenko 040bd32424 fix: Remove duplicate import of 'os' in patchwheel_test.go 2025-03-03 20:38:14 +01:00
Denis Bilenko (aider) 6babde4ae5 refactor: Update deprecated Go constructs to modern Go 1.24 practices 2025-03-03 20:37:05 +01:00
Denis Bilenko c8daa445b1 wip; add 2 digits after seconds; check outpout; use -q 2025-03-03 20:34:44 +01:00
Denis Bilenko 3888654ac6 Initial version 2025-03-03 17:25:12 +01:00
Denis Bilenko (aider) 86d7606304 refactor: improve test command execution with runCmd and captureOutput helpers 2025-03-03 16:51:02 +01:00
Denis Bilenko 8b91c207db fix: Correct variable name in runCmd and update venv path in test 2025-03-03 16:50:43 +01:00
Denis Bilenko (aider) 9c58b2eeaa refactor: update tests to use t.TempDir(), uv, and pyproject.toml 2025-03-03 16:44:14 +01:00
Denis Bilenko c0cd244e22 refactor: Add context import and TODOs for test improvements 2025-03-03 16:44:05 +01:00
Denis Bilenko (aider) 5276a5b461 refactor: Move version parsing logic from parseMetadata to caller 2025-03-03 16:20:01 +01:00
Denis Bilenko 64e7ad779a refactor: Add context import and comment for version parsing in patchwheel.go 2025-03-03 16:19:54 +01:00
Denis Bilenko (aider) 174db9432c feat: add context parameter to PatchWheel function 2025-03-03 16:17:29 +01:00
Denis Bilenko fd8f65a9da refactor: Simplify version parsing and add logging in PatchWheel 2025-03-03 16:17:13 +01:00
Denis Bilenko (aider) c814e86cf4 refactor: use constant for "Name:" prefix in metadata parsing 2025-03-03 16:13:52 +01:00
Denis Bilenko (aider) b9357fa8d2 refactor: simplify Name field parsing in parseMetadata function 2025-03-03 16:13:14 +01:00
Denis Bilenko 8bcf9ac2fe clean up 2025-03-03 16:12:32 +01:00
Denis Bilenko (aider) 965b250d89 refactor: simplify version parsing in parseMetadata function 2025-03-03 16:06:49 +01:00
Denis Bilenko cfbe899116 wip 2025-03-03 16:05:18 +01:00
Denis Bilenko 5c146ca57a
Synchronize logging in cmdio (#2418)
## Changes
Add mutex synchronization in cmdio logger Log() method.

## Why

Since we issue multiple calls to underlying writer, we should lock the
whole method, otherwise we can get broken messages. One that can be
easily reproduced today is

```
 hyperfine -m 100 --show-output 'go test ./acceptance -run ^TestAccept$/^bundle$/^artifacts$/^whl_multiple$ -count=1'
...
            -Uploading my_test_code-0.0.1-py3-none-any.whl...
            -Uploading my_test_code_2-0.0.1-py3-none-any.whl...
            +Uploading my_test_code-0.0.1-py3-none-any.whl...Uploading my_test_code_2-0.0.1-py3-none-any.whl...

Error: Command terminated with non-zero exit code 1 in benchmark iteration 54. Use the '-i'/'--ignore-failure' option if you want to ignore this. Alternatively, use the '--show-output' option to debug what went wrong.
```

An alternative could be to prepare a message fully in a local buffer and
write it in one call (I’m assuming underlying writer is still
synchronized). However, that’s more complicated and unclear if it’s
worth it, perf-wise.

## Tests
With this change I’m running the same hyperfine command with 1000
iterations with no failures.
2025-03-03 13:42:43 +00:00
shreyas-goenka bc299cafb8
Add warning when variable interpolation is used for auth fields (#2399)
## Changes
This PR adds a warning which gives users clear guidance when they try to
use variable interpolation for an auth field.

## Tests
Modify existing acceptance test.
2025-02-27 15:58:48 +00:00
Denis Bilenko c1f835f951
acc: Print full URL and request body for missing handlers (#2394)
## Tests
Manually, I have a test that fails.

Before:

```
=== NAME  TestAccept
    server.go:195:

        ----------------------------------------
        No stub found for pattern: GET /api/2.1/clusters/get

        To stub a response for this request, you can add
        the following to test.toml:
        [[Server]]
        Pattern = "GET /api/2.1/clusters/get"
        Response.Body = '''
        <response body here>
        '''
        Response.StatusCode = <response status-code here>
        ----------------------------------------
```

After:
```
    server.go:203: No handler for URL: /api/2.1/clusters/get?cluster_id=0717-132531-5opeqon1
        Body: [0 bytes]

        For acceptance tests, add this to test.toml:
        [[Server]]
        Pattern = "GET /api/2.1/clusters/get"
        Response.Body = '<response body here>'
        # Response.StatusCode = <response code if not 200>
```
2025-02-27 13:07:48 +00:00
Denis Bilenko e2db0cd0e2
Remove bundle.{Seq,If,Defer,newPhase,logString}, switch to regular functions (#2390)
## Changes
- Instead of constructing chains of mutators and then executing them,
execute them directly.
- Remove functionality related to chain-building: Seq, If, Defer,
newPhase, logString.
- Phases become functions that apply the changes directly rather than
construct mutator chains that will be called later.
- Add a helper ApplySeq to call multiple mutators, use it where
Apply+Seq were used before.

This is intended to be a refactoring without functional changes, but
there are a few behaviour changes:
- Since defer() is used to call unlock instead of bundle.Defer()
unlocking will now happen even in case of panics.
- In --debug, the phase names are are still logged once before start of
the phase but each entry no longer has 'seq' or phase name in it.
- The message "Deployment complete!" was printed even if
terraform.Apply() mutator had an error. It no longer does that.

## Motivation

The use of the chains was necessary when mutators were returning a list
of other mutators instead of calling them directly. But that has since
been removed, so now the chain machinery have no purpose anymore.

Use of direct functions simplifies the logic and makes bugs more
apparent and easy to fix.

Other improvements that this unlocks:
- Simpler stacktraces/debugging (breakpoints).
- Use of functions with narrowly scoped API: instead of mutators that
receive full bundle config, we can use focused functions that only deal
with sections they care about prepareGitSettings(currentGitSection) ->
updatedGitSection. This makes the data flow more apparent.
- Parallel computations across mutators (within phase): launch
goroutines fetching data from APIs at the beggining, process them once
they are ready.

## Tests
Existing tests.
2025-02-27 11:41:58 +00:00
Denis Bilenko b6bf035e7f
Skip serverless prompt in default-python (default is no) (#2388)
## Tests
Manually running 'bundle init default-python' - no question about
serverless.
2025-02-26 15:58:53 +00:00
Denis Bilenko ab3d82e32e
default-python: Swap order of yes/no in serverless template (#2386)
## Changes
Since at this moment we set default to 'no', interactively it should
also default to 'no'. However, it just uses the first option.

## Tests
Manually running `cli bundle init default-python`
2025-02-26 14:45:32 +00:00