Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Trailblazer now supports trading like stories do :)
    Artem Malyshev
    @proofit404
    Hi guys, I post some updates on substories conditionals dry-python/stories#76
    matrixbot
    @matrixbot

    lig > <@gitter_proofit404:matrix.org> Hi guys, I post some updates on substories conditionals dry-python/stories#76

    looks promising. need to try it.

    lig Artem Malyshev (Gitter): I wonder is it possible to use anything instead of I? So, self would also be possible to use
    Artem Malyshev
    @proofit404
    Yes, any name. I described it in the FAQ. https://stories.readthedocs.io/en/latest/faq.html
    Ghost
    @ghost~576aa099c2f0db084a1f5559
    @proofit404 asking about >> syntax. Will it work well with all of these stuff? https://docs.python.org/3/reference/expressions.html#operator-precedence
    And one more question. In languages where we have pattern matching out of the box, we can control how left side is built. What can we do here to limit different user attempts to write something like: when(next(Instance(x, 4, force=True)) >> ... ?
    Artem Malyshev
    @proofit404
    Do you mean other operators?
    Ghost
    @ghost~576aa099c2f0db084a1f5559
    yeap
    Artem Malyshev
    @proofit404
    Other operators are meaningless for dsl. I plan to inlement the right shift only and deny other operators in linter.
    Artem Malyshev
    @proofit404
    Does it make sense?
    Ghost
    @ghost~576aa099c2f0db084a1f5559
    Yes, it does.
    Artem Malyshev
    @proofit404

    And one more question. In languages where we have pattern matching out of the box, we can control how left side is built. What can we do here to limit different user attempts to write something like: when(next(Instance(x, 4, force=True)) >> ... ?

    Sorry, did not see it on my mobile. I think we should not restrict this. The only thing we care is a reference to the value. If user care about code readability, he/she will not write function calls inside when. If the user does not care, what is the point to use dsl in the first place?

    Ghost
    @ghost~576aa099c2f0db084a1f5559
    Artem Malyshev
    @proofit404
    I've done a talk about POC pattern matching implementation done in Python. It looks like this https://github.com/proofit404/proofit404.github.io/blob/master/talks/pattern-matching-in-python/test_patterns.py
    To be honest I just want to give the user an ability to check context variable in one place. I do not plan to implement special syntax for variable unboxing, head/tail comparison, or recursion. If == against value is not enough, user can pass a predicate function.
    Artem Malyshev
    @proofit404
    Or write its own object implementing __eq__ magic method, and do fancy stuff like when(_) or similar.
    Artem Malyshev
    @proofit404
    Hi guys, I wrote documentation for execution rules used in stories https://stories.readthedocs.io/en/latest/execution.html Please, check this out.
    Also, now it's unclear to me how to express everything described there in DSL variant from dry-python/stories#75
    Artem Malyshev
    @proofit404
    Hi guys, I'm planning to try poetry for dependencies management in all dry-python projects. But I'm worries about read the docs issue mentioned here https://twitter.com/playpausenstop/status/1063404164154314757 Anyone has experience in it?
    Ghost
    @ghost~576aa099c2f0db084a1f5559
    @proofit404 yes, I am using poetry for all my project. Feel free to assign me on review.
    Artem Malyshev
    @proofit404
    Did you experience any problems with readthedocs service?
    Ghost
    @ghost~576aa099c2f0db084a1f5559
    yes, it does not work at all with poetry. wemake-services/wemake-django-template#572
    as a workaround I use two dependency files. Like here: https://github.com/wemake-services/wemake-python-styleguide/tree/master/docs
    Artem Malyshev
    @proofit404
    Thanks! Will look at it after long postponed stories release.
    By the way, I put embedded gitter chat in all docs sites.
    Artem Malyshev
    @proofit404

    @lig After the first public release I think we should try to build a class based DSL.

    I write my thoughts on this process in the FAQ https://stories.readthedocs.io/en/latest/faq.html#what-is-the-best-way-to-prototype-my-own-dsl-look-and-feel

    Can you start slowly rewrite examples module?

    Maybe PR will work for us?

    Ghost
    @ghost~576aa099c2f0db084a1f5559
    How do you like do notation approach?
    Artem Malyshev
    @proofit404
    At the first look, it harms readability a little bit. I'll play with it after 0.9 stories release. But I really like it approach to avoid Success and Failure. Still unclear to me how to handle Skip.
    Ghost
    @ghost~576aa099c2f0db084a1f5559
    @proofit404 btw, I invite you to join our slack channel. Invites: https://slack.python.ru/ Slack: http://python-ru.slack.com
    we discuss a lot of things, including dry-python
    Igor S. Morozov
    @Morozzzko

    Ohai

    Still unclear to me how to handle Skip

    Just like you would do in plain Python. Using conditionals.

    The whole point of Do is that you don’t have to build your own DSL. You’ll be able to use plain Python (or Ruby) code instead of some fancy DSL which gets pretty complicated

    After over two years of use & contribution to the Ruby library, we dropped it and switched to plain monads. The complex DSL provides little to no value when we have a special syntax which makes it easier to work with monads.

    The worst thing is: it’s hard to wrap multiple steps into a database transaction. My colleague managed to write an around step, but it was pretty complicated

    Ghost
    @ghost~576aa099c2f0db084a1f5559
    I thought about providing save_points into this workflow. real world example: I have a complicated task resolution workflow in my bot (here's some details about this workflow: https://www.draw.io/?lightbox=1&highlight=0000ff&nav=1&title=billing.xml#Uhttps%3A%2F%2Fraw.githubusercontent.com%2Fwemake-services%2Fmeta%2Fmaster%2Fprocesses%2Fdevelopment.xml) so, sometimes I need savepoints inside my transactions, because things fail sometimes. and I still need some data to be saved. how can this be achieved right now?
    Igor S. Morozov
    @Morozzzko

    Oh I just realized something

    Still unclear to me how to handle Skip

    Skip essentially means that the function performed something and returned the input. Practically, it’s just a function which accepts an x and returns Success(x). That’s how you handle Skip.

    There’s probably no need to add any extra abstractions. Moreover, PEP 20 advises against that

    Artem Malyshev
    @proofit404
    Hi Igor, welcome to the dry-python community!
    I came to the DSL because I do not want described business logic looks like this:
    https://dry-python.org/static/slides/#/15
    I prefer it to look this way:
    https://dry-python.org/static/slides/#/17
    I agree that DSL with lots possibilities is hard to reason about. Instead I want to stories DSL be so limited it force the user to explain his/her thoughts in a straightforward way.
    Artem Malyshev
    @proofit404
    Current design does not provide any help in wrapping part of the story (a few steps in between) in a database transaction.
    Artem Malyshev
    @proofit404

    I plan to provide Rollback result type to the return types. This is how I see it:

    • You write story using functions, not methods.
    • You use story.mount method to attach this story to it steps.
    • Steps can be an instance of your class own class, or an Injector from the dependencies.
    • Each step definition is an object with two methods do and undo
    • When story is executed normally it calls steps.step.do(ctx)
    • If any of this method returns Rollback() result the whole story will be "played" in the reverse order using steps.step.undo(ctx)
    • Rollback.Current() will rollback only this substory. Caller story will be continued.

    What do you think?

    Here is an issue for future discussion: dry-python/stories#88
    Artem Malyshev
    @proofit404
    @Morozzzko Skip works on substories, not current step. More info here: https://stories.readthedocs.io/en/latest/execution.html#skip
    As for wrapping each step with decorator/context manager: dry-python/stories#14
    Artem Malyshev
    @proofit404
    I just released stories 0.9! This is the first release which was announced in public :heart: https://stories.readthedocs.io/en/0.9/
    Ghost
    @ghost~576aa099c2f0db084a1f5559
    @proofit404 this new idea looks interesting. wanted to share with you https://github.com/zorbash/opus
    Artem Malyshev
    @proofit404
    Time learn
    elixir I guess))