-
Notifications
You must be signed in to change notification settings - Fork 296
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
feat(compose)!: implement compose v2 with improved typing #426
Conversation
It's taken from
https://developer.hashicorp.com/terraform/language/functions/one - what
about "get_first_element_or_raise"?
…On Thu, Feb 29, 2024, 6:13 PM Jan Katins ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In core/testcontainers/compose/compose.py
<#426 (comment)>
:
> +class PublishedPort:
+ """
+ Class that represents the response we get from compose when inquiring status
+ via `DockerCompose.get_running_containers()`.
+ """
+
+ URL: Optional[str] = None
+ TargetPort: Optional[str] = None
+ PublishedPort: Optional[str] = None
+ Protocol: Optional[str] = None
+
+
+OT = TypeVar("OT")
+
+
+def one(array: list[OT], exception: Callable[[], Exception]) -> OT:
I found this functions not so easy to understand: the naming does not
imply what it does (e.g. it misses a verb), one has to read at the usage
place the second argument/ the exception message to get a feeling what's
happening in it. On the other hand, it doesn't really replace much
duplicated code: It replaces two three-line if-clauses with two one-line
one(...) calls but you need to convert the straight exception ´raiseinto alambda`.
But it also has 6 lines of definition.
if len(array) != 1:
raise Exception(....)
return array[0]
vs
return one(array, lambda: Exception(...))
Personally, I feel that this is less readable and the longer if version
is clearer and (with two places) even overall shorter.
—
Reply to this email directly, view it on GitHub
<#426 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACECGJFDVKAQMZ24YWDACULYV7I43AVCNFSM6AAAAABDQKELHWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTSMJQGE2DCNJQGI>
.
You are receiving this because you authored the thread.Message ID:
***@***.***
com>
|
ok, so, oops - i can pass the tests locally on macos and ubuntu 22.04 - but not on ci. ipv4 / ipv6 advice totally welcome. maybe i take the previous approach of just returning the first possible answer, given that is passes my test of actually giving the right port for the right service or something? |
|
@alexanderankin, does it make sense to add a wait_for_healthy method that waits for the container status to be correct? |
im not sure, the wait method is kept from before - just the standard http wait but parametrized, from the previous api of this module |
removed fmt:off guards and it is definitely tougher on the eyes (and the if there are no better ideas about how to merge this, its probably better to just merge? |
I agree, but that's standard Python for you. On the array formatting (rip pretty code) I am happy for you to try to reduce the line length to 100 and see if that helps (on another PR). Thanks for accommodating my comments though! 🙏 💚 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for a first pass. The only thing I can see is to add more tests/examples, but there is no point in delaying this PR from being merged.
You did a great job! 💚
🤖 I have created a release *beep* *boop* --- ## [4.0.0](testcontainers-v3.7.1...testcontainers-v4.0.0) (2024-03-06) ### Release Notes The breaking changes are the ones we were able to easily track. If you spot any new issues between `3.7.1` and `4.0.0`, please do report it and we'll do our best to fix everything. The release is now Some kudos from @totallyzen to folks who helped a great deal in starting things again: - kudos to @alexanderankin for his contribution on #426 - kudos to @jankatins for feedback on various PRs including - kudos to @max-pfeiffer and @bearrito for their contributions as well ### ⚠ BREAKING CHANGES * **compose:** implement compose v2 with improved typing ([#426](#426)) * **core:** add support for `tc.host` and de-prioritise `docker:dind` ([#388](#388)) ### Features * **build:** use poetry and organise modules ([#408](#408)) ([6c69583](6c69583)) * **compose:** allow running specific services in compose ([f61dcda](f61dcda)) * **compose:** implement compose v2 with improved typing ([#426](#426)) ([5356caf](5356caf)) * **core:** add support for `tc.host` and de-prioritise `docker:dind` ([#388](#388)) ([2db8e6d](2db8e6d)) * **redis:** support AsyncRedisContainer ([#442](#442)) ([cc4cb37](cc4cb37)) * **release:** automate release via release-please ([#429](#429)) ([30f859e](30f859e)) ### Bug Fixes * Added URLError to exceptions to wait for in elasticsearch ([0f9ad24](0f9ad24)) * **build:** add `pre-commit` as a dev dependency to simplify local dev and CI ([#438](#438)) ([1223583](1223583)) * **build:** early exit strategy for modules ([#437](#437)) ([7358b49](7358b49)) * changed files breaks on main ([#422](#422)) ([3271357](3271357)) * flaky garbage collection resulting in testing errors ([#423](#423)) ([b535ea2](b535ea2)) * rabbitmq readiness probe ([#375](#375)) ([71cb75b](71cb75b)) * **release:** prove that the release process updates the version ([#444](#444)) ([87b5873](87b5873)) * test linting issue ([427c9b8](427c9b8)) ### Documentation * Sphinx - Add title to each doc page ([#443](#443)) ([750e12a](750e12a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
relates to #306, #358