« first day (4606 days earlier)      last day (335 days later) » 

1:52 AM
@CeliusStingher ...but I asked you to confirm if it's fixed in pandas 2.0? The doc clearly deprecates using infer_date_format. Anyway, solution is that errors='raise' is your friend, don't use 'coerce; pass in/innfer your own list of possible format_strings and iterate over it.
 
 
2 hours later…
3:35 AM
@PaulMcG ..the joy of testing...
 
 
3 hours later…
6:41 AM
Does someone has any idea why "NameError 'null' is not defined" occurs here ? stackoverflow.com/q/76340767/13629335
 
@Thingamabobs Does you need None?
No
 
I have googled it myself, I can't spot any json file or null as a name in this script.
 
7:26 AM
Notebooks are inherently stored as json. You will occasionally notice this in commits to github where, for whatever reason, the underlying json is stored and not displayed as a notebook. It's quite annoying, actually
 
Can't follow you. Is it a response on me anyway ?
 
Yes, it was a response to you. You said you can't see any json in the code, but the code itself is json when it's in a notebook
At least, that's the underlying representation in certain cases
 
Either PyInstaller has a bug or OP used it incorrectly somehow
 
All they probably need to do is copy/paste it into a normal .py script and do the compilation again
 
Based on my experience with python-to-exe converters, there's a 99% chance it's the former
 
7:37 AM
That's also why it's complaining about a line that "doesn't exist" in their code - it actually does in the expanded json representation
 
I'm not enough of a programmer to understand this conversation, to be honest. :P What I seem to get is "PyInstaller is buggy" and when using a Notebook as machine to run the code you end up with a json file as code ? LOL :D Pretty sure I'm unable to give a qualified answer to OP.
 
I don't know the actual structure, but let's say your notebook has this:
print("hello")
print("world")
That ipynb will actually be stored as:
[{
    'line': 1,
    'code': 'print("hello")'
},
 {
    'line': 2,
    'code': 'print("world")'
},
]
Because, reasons
 
I see.. so with notebook you mean the file that contains the code and this is related to how ipython works. Ok, thanks for explaining it to me.
 
Yeah. The actual blob for each line is more complicated than that, but it carries metadata about each line. That's what I was saying about commits to github. I don't use ipynbs and I see a lot of commits where it's perfectly intelligible as a notebook. Then other times, it goes through as JSON garbage which is unintelligible in the grand scheme of things. I don't know what flicks that switch
Good way to get your LOC committed up, though :D Sneaky data scientist types
 
7:57 AM
I have a personal question on a different matter. I try to find the right name and maybe some input to an adapter like design pattern. Could someone confirm that it is in fact an adapter pattern or does someone see a better approach to something like the following?
class Adapter:

    def __init__(self, adaptee, ref):
        self.adaptee    = weakref.proxy(adaptee)
        self.ref        = ref

    def info(self, id_=None):
        return self.adaptee.info(self.ref, id_)

class Adaptee:

    def __init__(self):
        return None

    def info(self, ref, id_):
        return 'something'

    def serve_adapter(self, widget):
        return Adapter(self, widget)
 
Well, we don't really know what the code is doing, so it's hard to suggest a better approach. But yes, that's an adapter pattern
 
Basically the whole purpose of this is to have a single instance of Adaptee, where Adaptee is communicating with the TCL interpreter and the Adapter is shared among the widgets and do the widget specific operations.
 
What's the purpose of the adapter in that setup? Why don't the widgets use the Adaptee directly?
 
The idea was to have a clean distinction between what is commonly needed for the interpreter and what is needed for the widgets. That's why I choose this approach over a BaseClass. The adapter should make distinction between the types of widgets and avoid messy and repetitive code.
 
Ok, that sounds reasonable to me
 
8:08 AM
does this makes sense ? Because, I thought about using simply decorators too. But this would probably need dark magic where I inspect the calling instance and this doesn't feels right.
Ok, thank you.
 
What does a .exe actually do here? That question has piqued my interest a bit now because it looks like the literal JSON of the file is now just being interpreted as a python object which blows up when it hits null. But that's a compile-time error, not a runtime error, surely?
Like, surely PyInstaller needs to actually run a python interpreter when it's doing its thing?
 
There isn't really a compilation in the traditional sense, it basically just bundles the python code and the python interpreter into a single exe file
 
But I would have thought it would try make bytecode at the very least
Ok, well pending that one mystery, I can probably answer that question now
 
Bytecode as in .pyc files? That won't crash just because a variable isn't defined
 
8:32 AM
Interesting. I'm not sure why I find that surprising but I guess it's just because I'm only used to .pyc appearing after actually running the code, but I guess there's nothing stopping that conversion happening without running the file
 
What surprises me is that a python error is handled by the the tcl interpreters bgerror. Otherwise I really don't know where the error window is comming from.
 
9:27 AM
Surely that's just because it's a windows executable?
Time to play a bit with byecycle. Arne's gonna love what I do with his immaculate typing if I get something working for the plots
 
 
1 hour later…
10:51 AM
I got distracted for a bit so just coming back to that. @Arne I've not used pdm before; is the default to make the package editable? I'm looking at this but it doesn't seem to clarify for me that byecycle itself should be editable. I can see that it is, I just can't find anything you've configured for it e.g. in the TOML
It was painless to install, and I actually usually want the -e flag. I'm considering this packaging setup for my own projects going forwards. I just can't seem to pin down that exact behaviour in the docs
 
11:13 AM
It also hasn't dropped a .egg like -e would normally do
 
yeah, the self-install is always in editable mode. they inherited that design from poetry, so they might have forgotten to mention it. so the only option during install is --no-self
the machanism of editable install that pdm follows is described here: peps.python.org/pep-0660, I think the edd-link stuff is by now considered legacy/an implementation detail from setuptools specifically
 
Thanks for the clarification :) I've been a dinosaur for too long in packaging
 
*egg-link
ignoring the topic for the last decade or so was probably good for mental health, though. it's only since recently that things have been getting sane-ish
 
@Arne do you know how I could just get the dict from byecycle, so I can use it how I want instead of plotting it?
(I believe the version you did in your gist.github returned a dict at least)
 
and there is an example on the readme if you search for "alternatively".
 
11:25 AM
thanks, didn't know you finished the docs too :)
too bad it output a json, since I wanted something simple like a normal python Dict, where each key was a python file from the project being scanned, and each value of each key would be a list containing every imported module
I managed to get something close with your gist.github version, but didn't continue working on it last time
 
Well, that can still be represented as JSON. And you could deserialize it. What is the use case you're missing that you can't already do?
 
ah, probably nothing is missing, was just something I wanted to get so it's simpler for some external utility I wanted to make for it
I guess I could also get used to the json output
 
It's static analysis so I don't know whether you could embed it in your python program, but it wouldn't be much effort to launch as a subprocess of your own code and snag the output, parse it and do work with that as an actual dict
 
true, guess I'll try that too
thanks for the ideas
 
maybe I misunderstand, but do you mean something like this?
 
11:31 AM
Or, just add to the library itself? I'm not sure what functionality you want to do with this output
 
from byecycle import run
cycles, *_ = run("requests")
simple_mapping = {module: [*imports] for module, imports in cycles.items()}
 
In danger of not have gotten the point but isn't that close to sys.modules ?
 
gives me a dictionary where the keys are all modules in requests, and their value is a list of all local imports
 
@Thingamabobs it kinda is, but then you'd have to actually run the code/import the module. Here it's using AST parsing, so it does not actually run any code, it just parse it
 
I see, thanks
 
11:33 AM
it's good when you want to do analysis on code that you don't want or don't have to trust. It's also perhaps faster than actually running/evaluating the code, since parsing it does not use as much resources
 
yeah, the point is that if you got cycles in your project, you can't run it
 
@Thingamabobs The context to all this discussion starts here
@NordineLotfi It's not even about resources. If you use something like spyder and it resolves broken paths then you're literally firefighting one import issue after another because the program simply won't run. You can't see the bigger picture to actually make sense of the circular imports
 
@roganjosh yeah, here I meant this strictly for AST parsing, but you're right
I guess if you have a large codebase and you want to do code analysis, you probably don't want to evaluate the whole code, so parsing it is faster
 
11:48 AM
@roganjosh Have faced this issue in the past multiple times and it took me forever till I found something that worked for me. Don't know if you currently do so, but what I have done is to structure my package into multiple modules and each module has it's own __init__ file.
 
I didn't break it. I'm quite comfortable in building packages. What is an issue is if you try to package code from people that don't think about package structure, especially when their tools are fixing broken imports for them
This is a big thing in Data Science, for example (which is why I keep mentioning Spyder). It's a bunch of standalone modules that resolve imports that really just don't work outside of their IDE. When you actually try move that into production, it can go boom
 
doesn't sounds like fun to reverse their brain knot. :/
 
byecycle
 
:D brilliant name for it :)
 
That one's all Arne's creation. I think you're up to speed on our discussion now
 
12:08 PM
great work! But hopefully I don't need to make use of it anytime soon. ^^
 
 
9 hours later…
9:08 PM
Hi all, have a basic question. I have a jupyter notebook that i'm running in aws platform. I can clone a git repository in that notebook, after that i basically trigger or run a python file , in that repo. but i want to pass the branch name as a parameter to that python script, say if i run -> !git branch, it will give me the current git branch i'm on and i want to pass that name to my script from the notebook as an argument, python myscript branch_name
any suggestions. was going to write a SO question for this , but not sure if it will qualify
 
Use subprocess.run to execute git branch?
 
10:09 PM
You can't just run code on "aws". Is it an EC2 instance?
 

« first day (4606 days earlier)      last day (335 days later) »