@blakeNaccarato@fosstodon.org avatar

blakeNaccarato

@blakeNaccarato@fosstodon.org

Research assistant studying boiling and condensation phenomena in the Active Materials and Smart Living laboratory at the University of Nevada, Las Vegas.

In addition to research-based projects, my GitHub also features my hobby pursuits. I am interested in teaching Python and the intersection between research and modern project tooling.

This profile is from a federated server and may be incomplete. Browse more on the original instance.

ehmatthes, to random
@ehmatthes@fosstodon.org avatar

Where do people put guidelines around implementation choices in a project?

For example I want to make a note to use path.read_text() instead of with open(), and a brief rationale.

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@ehmatthes
@diazona @SnoopJ

I like how Scientific Python (eg. link 1) also associates linting rule numbers with their narrative docs. A linter backing up your docs helps surface advice.

I use Sourcery and it has a linting rule for just what you ask (2), but contributors must create a free account 🫠

You could write your own linting rules in Fixit or bellybutton (3/4) in a pinch!

(1) https://learn.scientific-python.org/development/guides/docs/#readthedocsyaml
(2) https://docs.sourcery.ai/Coding-Assistant/Reference/Rules-and-In-Line-Suggestions/Python/Default-Rules/path-read/
(3) https://github.com/Instagram/Fixit
(4) https://github.com/hchasestevens/bellybutton

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@ehmatthes

Thanks!

Sourcery has lots of autofix Pythonic refactorings, encouraging comprehensions, guard clauses, loop rewriting, VSCode integration, and good supporting docs.

I recommend it to beginners, but now they only let you run locally on public GitHub clones unless paying. So I say it's worth a look, but not a blanket endorsement.

They also bolted on an AI assistant that I skipped the "Opt-in" for, and disabled Sourcery code lens. The linter is their killer feature, in my opinion!

gvwilson, to random
@gvwilson@mastodon.social avatar

I want the equivalent of 'lint' or 'ruff' for GitHub repos. Does the repo name match a pattern? Are the right issue labels set up? Et cetera. I can write a script to do this, but if it already exists, a pointer would be welcome: how do you manage the 780 repos your org has?

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@gvwilson

Thanks to @henryiii for showing off the web hosted version of Scientific Python's "Repo-Review" tool recently, which also has a CLI, and does just that, running a repo against certain established rules of best practices (tied to their documentation).

But I think the CLI also supports writing your own rules as plugins, or requesting or contributing back upstream. Could be a good framework for checking your repos against a list of such conditions!

https://learn.scientific-python.org/development/guides/repo-review/

jonny, to random
@jonny@neuromatch.social avatar

trying to develop a zotero plugin is the most dogbrained developer experience in the universe, but i am not allowed to help with the docs because i haven't been doing it for several years. so i wonder why it's so hard.

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@jonny

I don't know if this would help, but I like the Zotero plugins Better BibTeX for their preferences menu, and Zutilo's context menu customization. I wonder if their approaches might be useful as inspiration for your plug-in implementation.

A bummer that the developer experience is fumbling around in the DOM, though, I had a similarly difficult experience doing some hacky Windows stuff with pywin32.

https://github.com/retorquere/zotero-better-bibtex

https://github.com/wshanks/Zutilo

jonny, (edited ) to Neuroscience
@jonny@neuromatch.social avatar

the last thing i would do is blame neuroscientists for the disfunctional US federal budgeting process that funds basic research at pennies on the dollar compared to war and subsidizing the rich. at the same time I also think we would probably have an easier time communicating to the public at large and building a political case for funding neuroscience if we focused less on publishing discrete papers and more on making our work into larger, cumulative projects that we could point to as a direct consequence of our funding. We should be able to say "here are all the things the BRAIN initiative funds and how they relate to one another" instead of having NIH Reporter and a handful of summary PDFs as the best resource at hand.

What do pieces like https://www.thetransmitter.org/funding/278-million-cut-in-brain-initiative-funding-leaves-neuroscientists-in-limbo/ point to?

the Brain Initiative Cell Atlas Network, which is pioneering single-cell atlases for the human brain and the mouse brain, and the FlyWire Connectome project, which mapped every neuron in the fruit fly brain and spinal cord.

BICAN, which has a ton of work that you can point to, is great, eg the "knowledge explorer" but even then it suffers from public intelligibility even though i know there's a lot more there - eg. the "tools" link from the homepage - https://www.portal.brain-bican.org/ - goes to some unintelligible RRID page. FlyWire is great ( https://codex.flywire.ai/ ) but the dependence on google infra and identity is just a pointless footgun.

point being, scientific infrastructure isn't just a matter of 'nice to have,' but is probably increasingly important to the survival of the discipline. If we can't point to what we've done as a coherent picture, it's very easy to cut funding and have it fly under the radar.

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@jonny

It would be nice if "do good science and science communicators will do the communicating for you," were true, but I guess you do need to do "scicom" intentionally.

I think Complexly's SciShow represents some of the best in video-based scicom, and they cover neuro often. Maybe it's reasonable to build scicom partnership into a research plan? But probably the grant funds can't be used for it, so I don't know how it would fit into the existing system.

https://complexly.com/partner/

nedbat, to python
@nedbat@hachyderm.io avatar

Quick packaging tip: if you ever find yourself wanting to type import src.anything or from src import anything, turn back. src should never be part of an import.

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@nedbat
@moehrenfeld Unintended literal src imports can sneak into code when using refactoring tools, as well. I've noticed that VSCode's "Move symbol to..." refactoring tool decides to import from src.my_package... instead of from my_package... on occasion, especially when moving symbols across the package boundary.

So check your import diffs when refactoring using such tools, it's sneaky because you never wrote it by hand.

jonny, to random
@jonny@neuromatch.social avatar

Check this out I made a templating system for a code generator for a linked data schema that can generate templating code for a linked data schema. Just add eval.

So about that whole "p2p triples with linked representations and interfaces" thing...

https://github.com/linkml/linkml/pull/2053

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@jonny

Okay so in your post, is this PR the templating system, pydanticgen the generator, and YAML the schema? Is string_serialization usually for adding units and such to make nice data reprs (that's cool)?

But here string_serialization could describe a schema evaled to generate another model? We XML now, billion laughs etc. Wild.

I feel like introducing myself to linkml in this way is like trying to learn Python by flipping directly to the metaprogramming chapter of Fluent Python.

jonny, to random
@jonny@neuromatch.social avatar

how do you get correct python type annotations for a class that is a proxy type for a set of types that can't be known in advance because it's designed as a plugin architecture where people might only have one of a few possible types installed? i guess the answer is dynamically generate a type stub file as an import side effect and make literally everyone mad at me lol

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@jonny

Over at svcs they're also dealing with typing limitations in an interface generating "service locator" framework that deals with generic/protocol funny-business.

They mention specific typing limitations briefly in the docs, and have a workaround for it. Also there's something about their approach to typing involving late binding. It's all a bit abstract to me, but maybe there's something relevant in their approach.

https://svcs.hynek.me/en/stable/typing-caveats.html

https://svcs.hynek.me/en/stable/glossary.html#term-Late-Binding

simon, to random
@simon@simonwillison.net avatar

Python asyncio question: I want to build a library that offers the same features in both sync and async formats

Are there any drawbacks to building it async, then providing a sync function which actually just calls asyncio.run(async_function(*args, **kwargs)) ?

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@simon I know this is probably the wrong answer, but I'm going to suggest it even if just to get a response as to why it's Not a Good Idea™️. Can you automatically generate the code for sync modules from the async ones with minor modifications (via ast or etc.) and ship a whole importable shadow of the async version? Ugly, terrible, bad idea I know!

jonny, to random
@jonny@neuromatch.social avatar

I havent been writing much about it here lately, but im getting pretty excited about what were about to give to neuroscientists (and then everyone else) - big changes in the data standards and tooling landscape, working on a new version of NWB that will be less something you convert your data to at the end, and more a set of tools and models for working with your data throughout an experiment. It'll be easier than not to standardize your data.

We're also building them on an interoperable schema language that will make it possible to use your data fluidly alongside other standards, with no clear border between them. And ill be making self-publishing your data literally the same act as sharing it within your lab.

A data backbone for a new kind of p2p born out of practical use :)

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@jonny I'm really excited about developments in data standards, especially ways to describe/schematize the shapes of data. Having a flexible and widely-adopted approach seems to be the way to go. Not too opinionated of a framework, backed by a specification, but with a proof-of-concept implementation (incorporating Pydantic is a safe bet, see also msgspec).

...

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@jonny

I'm reminded of Frictionless, which I'm considering using as my data descriptor layer in my dissertation code. I found NWB mentioned in the same breath as Frictionless in this NES paper while searching for connections between the approaches. I'm looking forward to seeing details of your approach, and benefits/differences it brings compared with Frictionless and others!

https://github.com/frictionlessdata/frictionless-py

https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8777234/

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@jonny Thanks for the details! I'll have to use Frictionless and grapple with how it interfaces with my data to better understand the additional benefits these extra concepts bring. Still on my data tooling journey 😅

I've used Pydantic to encode I/O and project layout, Pydantic+Pandera for some validation, and DVC for pipeline definitions. But I'm currently missing the formal data description component (outside of docs examples) which would facilitate use of my code by other researchers.

davep, to random
@davep@fosstodon.org avatar

It’s healthy if I keep watching this on repeat, right?

Right?!?

https://www.youtube.com/watch?v=6cs-A1rNvEE

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@davep What a fever dream. Glad to finally see a proper strand-type game on the horizon!

pamelafox, to random
@pamelafox@fosstodon.org avatar

anyone have fav python packages for parsing JSONPath?

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@pamelafox

I can't speak to packages that parse JSONPath strings into an AST or other representation, but I'm interested in hearing more about that use-case!

As for querying JSON, I like parsel as it rolls together CSS/XPath for XML/HTML, and JMESPath for JSON into a unified object representation supporting a fluent interface/method chaining.

But it uses JMESPath instead of JSONPath, so maybe not quite what you're looking for!

https://pypi.org/project/parsel/
https://jmespath.org/

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@pamelafox Gotcha. I hope you'll find JMESPath implementations across other languages, but I haven't looked.

My pipe dream would be a unified query language for all HTML/XML/JSON/YAML/TOML, but I'm sure that's impossible!

Not what you asked for but: For something that gets subsets of JSON similar to querying, but is Python-specific, msgspec structs look cool (see GeoJSON example). Haven't used it, but am keeping it in mind for this use.

https://jcristharif.com/msgspec/examples/geojson.html
https://pca.st/episode/6a9e3c32-47f6-48ad-aa35-56f6d4b00aac

pamelafox, to random
@pamelafox@fosstodon.org avatar

I just did a lecture on debugging in Python, and in one example, I override the sum() built-in. Students were shocked that Python let me override a built-in without any warning at all. Are there linters that check for that? Or modes to warn about it?

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@pamelafox

Installing flake8 and flake8-builtins extension would solve the immediate issue, provided students are using an IDE that supports flake8. Maintaining a set of student virtual environments with a bunch of flake-8 plugins may get unwieldy.

I link to Ruff's doc since ruff bundles hundreds of these rules, and can be configured by TOML to selectively enable rules to reduce overwhelm and target outcomes. Higher startup cost, but easier to juggle rules.

https://docs.astral.sh/ruff/rules/#flake8-builtins-a

dabeaz, to random
@dabeaz@mastodon.social avatar

How did it actually get to this?

Looking at you enum module.

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@dabeaz

Do you mean that match semantics are inconsistent in such a way that it's difficult to write a properly exhaustive set of cases, meaning you have to resort to Enums to avoid the footgun? Or something else entirely?

I only use match and Enum sparingly. typing.Literal works okay, but of course makes no runtime guarantees.

Another place I see Enums actually useful is at the interface with lab hardware, mirroring the hardware's domain-specific set of codes expected over serial.

blakeNaccarato, to random
@blakeNaccarato@fosstodon.org avatar

@willmcgugan @davep I was surprised to see Rich and Textual featured on Computerphile today! Dr. Valerio Giuffrida discusses the general concept of progress bars in computing, and uses Rich/Textual in an example implementation to illustrate the concept.

https://youtu.be/uHh0qpc1BR4?t=420

glyph, to random
@glyph@mastodon.social avatar

TIL Tkinter (and in fact, all of Tcl/Tk) is completely inaccessible to screen readers, so if you make apps for it, you're excluding blind users. This is a huge disappointment as I was really starting to find that it is a super handy little tool for form-based applications with few dependencies (exactly the sort that should be easy to make accessible), always available to Python.

It is … bizarre that it is 2024 and this hasn't been fixed yet. Has nobody blundered into an ADA issue here?

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@matt
@glyph

Are there other Python GUI framework providers that currently have a better accessibility story than Tkinter? If I can manage it in any given project, should I reach for Qt (via PySide, PyQt, etc.) instead? I'm aware of Kivy and Beeware's Toga as well.

For simpler UIs, I think I'll try out Textual next time I need a UI.

If only the Lighthouse score could be applied here, I guess it's harder to quantity accessible features in out-of-browser GUIs.

sethmlarson, to random
@sethmlarson@fosstodon.org avatar

There's a little gold nugget buried in Frontend Master's support for open source dependencies:

"we think it’s unhealthy for the ecosystem to have the larger projects sitting on multiple $100k of inactive funds in their Open Collective account while smaller projects go unrecognized."

100% agree. It's a bug to have an order of magnitude in OC beyond what a project spends in a year. Getting funding in the hands of projects which don't have enough is far more important.

https://frontendmasters.com/blog/how-were-supporting-open-source-maintainers/

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@sethmlarson I'm glad that GitHub bulk sponsoring is a thing now, it's a great idea. I've never heard of thanks.dev before but I guess I've got to add it to my growing file of sponsorship-related things now.

I would like to see more and cleaner mechanisms facilitate mass sponsorship like this, at the individual user scale. Ideally one would be able to use it for sponsorships outside of tech/dev, too, reducing decision fatigue esp. when you don't have much to give.

hynek, to random
@hynek@mastodon.social avatar

This has been bothering me forever: does anyone know why in VS Code in Python the import Quick Fix doesn’t work in tests?

Like: I write code with a symbol that isn’t imported yet. When I go on the squiggled symbol and press ⌘. in code within src/pkg_name, I always have to option Add “from X import Y”. If there’s multiple symbols with that name, I get them shown all.

If I do the same within tests, I get nothing except “Ruff (F821): Disable for this line”

Is this normal? Any leads?

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@hynek

I think VSCode's import quick fixes are served by Pylance, which in turn uses a bundled pyright install to sniff out symbols. I do have a working import quick fix for src symbols and stdlib/venv symbols when in tests. My dev environments usually have a single .venv.

It may be because of my include setting in pyrightconfig.json, or equivalently tool.pyright.include in pyproject.toml, like so:

[tool.pyright]
include = ["src", "tests", "docs"]

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@hynek

Heads up, I edited my first reply prior to reading this one. Maybe include option represents folders in which Pylance bothers to try quick fixes?

You may have to try a dummy project with minimal setup and single .venv to see if symbol quick fixes even work in that "happy path", and go from there.

Sorry, I know troubleshooting magic IDE tools is as bad as CI troubleshooting. The Python Language Server Output Window does echo Pylance config and import discovery, which may help.

mkennedy, to python
@mkennedy@fosstodon.org avatar

If, and a big IF, I were to do a @talkpython episode on “Working Full Time on Open Source” where the focus is truly doing open source for your own project full time (not say working for RedHat but they put you on OpenStack full time) type of episode, who should I invite? #python

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@mkennedy

You're probably already aware of anyone I can think of, but @charliermarsh of Astral/ruff and Dmitry Petrov of Iterative/DVC (DVC being a kind of pipeline orchestrator, Iterative growing out of that afaik).

hynek, to random
@hynek@mastodon.social avatar

This is weird to talk about since it always implies a certain amount of begging. Still, yesterday, I lost another Organization-level sponsor, which left me with exactly one (shout-out to ❤️ https://filepreviews.io! ❤️) & I have, at this point, lost more than 50% of GitHub Sponsors income in the past 12 months—which feels like a sad milestone. [1]

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@sethmlarson
@hynek

Are sponsorships just that much more sensitive to economic factors than to signals like alignment of interests between sponsors and sponsored activities? Is sponsorship decline actionable if the economic signal dominates? Does that entail outreach and surveys, or prioritizing different funding?

I've seen at least one recent anecdote of a similar decline in sponsorship of a particular YouTube channel, where a precipitous decline in sponsors this year has no obvious cause.

brianokken, to random
@brianokken@fosstodon.org avatar

Python Test 209: Testing argparse Applications

How do you test the argument parsing bit of an application that uses argparse?

https://testandcode.com/episodes/209-testing-argparse-applications

blakeNaccarato,
@blakeNaccarato@fosstodon.org avatar

@dws
@brianokken

While listening, I liked hearing "why", but it gets murky in the "how". I think it makes sense to do in audio what the blog/text cannot do as well. Focus on the "why" (e.g. you answered why define main()). Related anecdote also plays well. Be wary of treading the same ground as the blog post.

Bonus points for chapter markers, like in Python Bytes, referenced in episode notes, link blog post subheadings, links the "whys" in audio to the "hows" in text.

I like the pod rebrand!

  • All
  • Subscribed
  • Moderated
  • Favorites
  • megavids
  • thenastyranch
  • rosin
  • GTA5RPClips
  • osvaldo12
  • love
  • Youngstown
  • slotface
  • khanakhh
  • everett
  • kavyap
  • mdbf
  • DreamBathrooms
  • ngwrru68w68
  • provamag3
  • magazineikmin
  • InstantRegret
  • normalnudes
  • tacticalgear
  • cubers
  • ethstaker
  • modclub
  • cisconetworking
  • Durango
  • anitta
  • Leos
  • tester
  • JUstTest
  • All magazines