Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Wallet
Jun 19, 2006

cinci zoo sniper posted:

Viewing this through work environment prism, I prefer native > cli > web, for performance/power efficiency and consistent applicability of accessibility features.

In that context my preference for web is stronger than it is personally (I don't really give a poo poo for personal use) because web poo poo (at least now that flash is well and truly dead) has largely been designed to accommodate presenting reflowable content on devices of different sizes with different capabilities while other things haven't. If performance is a serious concern then native becomes a lot more attractive but it often isn't for me.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

QuarkJets posted:

the latest UI design trends in a GUI

For me it's not about the trends, it's about the flexibility to implement accessible designs that follow basic design principles. That's just much easier with HTML/CSS/JS.

Even something as simple as resizable windows are vastly harder to get right on a native UI compared to a web page.

QuarkJets posted:

as though web design isn't universally garbage anyway

It's not, you're just understandably biased by the fact that there are lot of aspects of the web that privilege lots of bad design. At the top of my mind currently the two main aspects driving design compromises on the web are low barrier of entry and revenue choices.

CarForumPoster
Jun 26, 2013

⚡POWER⚡
I'd like to send some of my Dash/Flask business tools to a lawyer friend who doesn't have python installed.

Any way to email them a zip file with everything needed to run my Dash/Flask app locally as a standalone? (Assume no environment variables or other weird stuff are required)

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

CarForumPoster posted:

I'd like to send some of my Dash/Flask business tools to a lawyer friend who doesn't have python installed.

Any way to email them a zip file with everything needed to run my Dash/Flask app locally as a standalone? (Assume no environment variables or other weird stuff are required)

I think PyInstaller will do it? It'll just make an executable of the whole thing for you.

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


Thermopyle posted:

For me it's not about the trends, it's about the flexibility to implement accessible designs that follow basic design principles. That's just much easier with HTML/CSS/JS.

Even something as simple as resizable windows are vastly harder to get right on a native UI compared to a web page.

I might agree with the first part, but I wouldn't really choose resizable windows of all things as an example, that's like the one thing native GUI libraries do for you. Maybe if you're really used to CSS it might seem difficult becuase it's different, but I've never really struggled with it in Gtk/Qt/Swing/.NET WinForms.

The one place where resizing is annoying are console GUI interfaces, it actually is a pain to do in something like curses.

e: I've never used or heard of pysimplegui though, no idea how finnicky that is. You might have a better time just using Qt.

Private Speech fucked around with this message at 01:28 on Jan 12, 2020

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Private Speech posted:

I might agree with the first part, but I wouldn't really choose resizable windows of all things as an example, that's like the one thing native GUI libraries do for you. Maybe if you're really used to CSS it might seem difficult becuase it's different, but I've never really struggled with it in Gtk/Qt/Swing/.NET WinForms.

The one place where resizing is annoying are console GUI interfaces, it actually is a pain to do in something like curses.

e: I've never used or heard of pysimplegui though, no idea how finnicky that is. You might have a better time just using Qt.

Yeah, I've got many tens of thousands of lines of Qt under my belt.

Private Speech
Mar 30, 2011

I HAVE EVEN MORE WORTHLESS BEANIE BABIES IN MY COLLECTION THAN I HAVE WORTHLESS POSTS IN THE BEANIE BABY THREAD YET I STILL HAVE THE TEMERITY TO CRITICIZE OTHERS' COLLECTIONS

IF YOU SEE ME TALKING ABOUT BEANIE BABIES, PLEASE TELL ME TO

EAT. SHIT.


Thermopyle posted:

Yeah, I've got many tens of thousands of lines of Qt under my belt.

Can't tell if it's sarcasm or not, but how would you go about doing simple screen scaling on the web?

I don't have that much web experience but from I've seen you basically end up making different designs for smartphones, tablets, etc., and then switching between them depending on the screen size, which doesn't seem dramatically easier. And you still need a library (or plural) for that.

The other option is just doing simple fixed ratio scaling with minimum element sizes, which is basically the default on native interfaces.

e: There's a lot of much more difficult-in-native things like callbacks, interface updates, graphical element scaling (as opposed to window scaling), fancy graphical effects and shaders, text editing fields, fonts, text styling, etc. which are easier to do via a web interface. Try making your cursor sparkle or highlight interface elements in Qt (I don't mean on mouse events, as part of a help guide or something). That's why I find it odd to pick something that's a relatively big part of what native GUI libraries do in the first place; you even get to pick which window layout manager you want to use, depending on which approach you want to take.

Private Speech fucked around with this message at 04:02 on Jan 12, 2020

Wallet
Jun 19, 2006

Private Speech posted:

I don't have that much web experience but from I've seen you basically end up making different designs for smartphones, tablets, etc., and then switching between them depending on the screen size, which doesn't seem dramatically easier. And you still need a library (or plural) for that.

Partially, but that's because you simply don't want content to be displayed the same way on a vertically oriented phone screen as you do on a big old computer monitor. CSS handles checking viewport sizes and switching styles/layouts just fine out of the box. A system like Bootstrap isn't set up (out of the box) for making completely different designs for different types of devices, it just has breakpoints that allow you to modify the sizes/layouts of elements at different screen sizes very easily.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Private Speech posted:

Can't tell if it's sarcasm or not, but how would you go about doing simple screen scaling on the web?

I don't have that much web experience but from I've seen you basically end up making different designs for smartphones, tablets, etc., and then switching between them depending on the screen size, which doesn't seem dramatically easier. And you still need a library (or plural) for that.

The other option is just doing simple fixed ratio scaling with minimum element sizes, which is basically the default on native interfaces.

e: There's a lot of much more difficult-in-native things like callbacks, interface updates, graphical element scaling (as opposed to window scaling), fancy graphical effects and shaders, text editing fields, fonts, text styling, etc. which are easier to do via a web interface. Try making your cursor sparkle or highlight interface elements in Qt (I don't mean on mouse events, as part of a help guide or something). That's why I find it odd to pick something that's a relatively big part of what native GUI libraries do in the first place; you even get to pick which window layout manager you want to use, depending on which approach you want to take.

It was non-sarcastic, but unnecessarily curt. Sorry.

I didn't really pick the best possible examples, I just picked my most recently-encountered examples.

That being said, I still hold that resizable windows are easier in the browser than in Qt.

First of all, modern web development focuses on responsive design. If you find you're really developing a separate interface for different devices, then you're doing web development wrong. I mean, you might have to do some things different if only because, for example, a huge table just isn't going to work on a mobile device.

Secondly, you highlight having to use a separate library as a downside, but that's kind of irrelevant since part of my point was that you should use a library:

Thermopyle posted:

for example, using React or Vue to develop a UI along with a web UI/UX toolkit is a breath of fresh air compared to any of the poo poo you can do with python.

So, given that I'm already advocating using a library, any of the major libraries come with easy and effective methods to adapt any layout to any display/window size.

Anyway, the three main reasons that come to mind at the moment that developing resizable windows are better in the browser rather than Qt:

1. CSS Grid and em-based media queries. With something like 5 lines of CSS you can convert your static app interface into a responsive interface, so in modern browsers you don't even need something like Bootstrap or any of the other UI toolkits, at least for the responsive interface part. I still recommend them for programmers because of the style constraints and guidelines they enforce.
2. A bajillion times larger community with lots of design guidance and best practices for resizing. (Us programmers need tons of design guidance).
3. UI toolkits and paradigms built around resizability. Native UI paradigms and widgets just aren't built around resizable windows. The modern web, by necessity, is. Arguably, nowadays people are more likely to be comfortable with web interface paradigms than they are with native UI paradigms.

I'm not going to die on this hill, because it's not a completely obvious win so it'd probably take a lot of back and forth to convince someone who doesn't believe it and, unfortunately, I just don't care that much. I'll just say as someone who has a ton of experience doing both frontend web development and python GUI development I think it's just as definite a win as being able to do any of the things in your edit.

Thermopyle fucked around with this message at 20:32 on Jan 12, 2020

Beef
Jul 26, 2004
Having worked in academic UI research, I am now working with pure CLI interfaces wanting nothing to do with any type of UI frameworks ever.
I loved tinkering with McClim and Morphic, even though they were way before my time.

gently caress the last decades of tweaking tinkering poo poo engineering nightmares that are in the end putting a different interface spin on a gridbag layout in a half-baked bugridden implementation full of hardcoded corner cases.

wolrah
May 8, 2006
what?

Beef posted:

Having worked in academic UI research, I am now working with pure CLI interfaces wanting nothing to do with any type of UI frameworks ever.
I loved tinkering with McClim and Morphic, even though they were way before my time.

I'm far from a professional programmer, but this is basically where I've ended up as well with my itch-scratching software. If I can avoid having to worry about a GUI in the first place I do exactly that.

If I need to have a GUI, I prefer web based when possible because it's the easiest to make work reasonably on basically any platform that matters.

Native frameworks are a last resort for when I need something that can't be easily done in a web interface.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

I'd be surprised if there were any python programmers that went for a GUI before a CLI.

(Just watch, there'll be someone who does)

QuarkJets
Sep 8, 2008

Yeah you don't make a GUI unless it's necessary, that's a lot of extra work no matter what framework you use.

Dominoes
Sep 20, 2007

This completely depends on the use case. CLI only works if you're writing programs for nerds.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Well it seems like we're talking about technical programs here.

But even if not, a CLI is often a good first draft that you can then wrap a GUI around.

mr_package
Jun 13, 2000
Are there any downsides/gotchas to using pyenv? (On MacOS)

Edit: and should I create a virtual environment with pyenv or with Poetry (or, with venv? e.g I could switch to python 3.7 with pyenv and then create a virtual environment with the venv of the activated Python, or Poetry can then do it on 3.7 instead of its default (on Mac) 2.7, or there is pyenv-virtualenv plugin, is that the best way..?)

I'm just wondering which of these is simplest in the end, when I go to package stuff up and deploy to servers, is there anything 'wrong' with any of these approaches or will they all work pretty much the same?

edit2: pyenv does use venv now: https://github.com/pyenv/pyenv-virtualenv#virtualenv-and-venv

mr_package fucked around with this message at 00:37 on Jan 14, 2020

Dominoes
Sep 20, 2007

Use Anaconda or the all-in-one tool I made. I'm convinced people liking the pyenv/poetry/virtualenv combo is mass psychosis, or I'm misunderstanding how they're intended to work.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Nowadays I don't use virtualenvs, poetry does and I don't worry about it.

I use poetry and pyenv because they always work well for me, they're widely used and understood by the community, and the time spent touching either of them is minuscule compared to the time spent working on the project itself.

I don't use Anaconda because of the friction between conda vs pip-installed packages, I usually don't have a need for any of the things Anaconda makes easier to install or I already use Docker in ways that negate Anaconda's use, and most developers I work with, documentation I read, and libraries I use are focused on pip/pyenv/virtualenvs rather than Anaconda.

I wouldn't say I "like" any of these tools...I'm indifferent because they're such a minuscule part of my development time. If for some reason Anaconda became the tool to use and the other tools became poo poo, it really wouldn't matter to me.

Dominoes
Sep 20, 2007

conda vs pip-installed packages that's the biggest reason I don't use conda myself. IIRC Poetry's 1.0 release fixed venv issues that made it pick the wrong py version.

NinpoEspiritoSanto
Oct 22, 2013




Poetry with pyenv here too. Seem to be the current du jour.

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Thermopyle posted:

I'd be surprised if there were any python programmers that went for a GUI before a CLI.

(Just watch, there'll be someone who does)

Does a jupyter notebook count? I love notebooks. Inline graphs/images and documentation style commenting (markdown cells) are the best.

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

CarForumPoster posted:

Does a jupyter notebook count? I love notebooks. Inline graphs/images and documentation style commenting (markdown cells) are the best.

Notebooks rule because literate programming never should have died. Unfortunately they still have all the same problems that literate programming had, mainly that they end up being great for roughly everything but production use

CarForumPoster
Jun 26, 2013

⚡POWER⚡

Phobeste posted:

Notebooks rule because literate programming never should have died. Unfortunately they still have all the same problems that literate programming had, mainly that they end up being great for roughly everything but production use

I use them for stuff I need to run once a day or so. Its nice because you get a really readable log file out of the end of it and you can force nbconvert to run every cell so it'll execute the steps even if there's a failure up stream.

For example at the end of my daily running ones it send an IM to an MS Teams webhook with pymsteams containing the important info and any errors.

SurgicalOntologist
Jun 17, 2004

Dominoes posted:

conda vs pip-installed packages that's the biggest reason I don't use conda myself. IIRC Poetry's 1.0 release fixed venv issues that made it pick the wrong py version.

I have used conda for what seems like a decade, never really think about if I'm using conda or pip, and have never had a problem. What symptoms of friction? Genuinely curious.

mr_package
Jun 13, 2000

Dominoes posted:

conda vs pip-installed packages that's the biggest reason I don't use conda myself. IIRC Poetry's 1.0 release fixed venv issues that made it pick the wrong py version.

Nope, Poetry still broken on MacOS if you're not using pyenv. The main dev is married to the idea that a system has an "active" python and when you call Poetry it should use that Python, even if it's python2 because-- as is standard-- 'python' points to python2 and 'python3' or python3.x points to python 3.

Now they did provide an 'env' command that lets you modify the environment of an already created system but because it will be python2 based by default you need to modify the .toml file to allow python 3 before you can run the env command to change it. Because a perfectly normal way to use a tool that automates/manages this stuff is to hand edit .toml files every time you create a project.

So basically if you want to use Poetry either use pyenv or setup a virtual environment / venv before running it.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

mr_package posted:

Nope, Poetry still broken on MacOS if you're not using pyenv. The main dev is married to the idea that a system has an "active" python and when you call Poetry it should use that Python, even if it's python2 because-- as is standard-- 'python' points to python2 and 'python3' or python3.x points to python 3.

Now they did provide an 'env' command that lets you modify the environment of an already created system but because it will be python2 based by default you need to modify the .toml file to allow python 3 before you can run the env command to change it. Because a perfectly normal way to use a tool that automates/manages this stuff is to hand edit .toml files every time you create a project.

So basically if you want to use Poetry either use pyenv or setup a virtual environment / venv before running it.


Is there any reason to not being using pyenv?

QuarkJets
Sep 8, 2008

mr_package posted:

Nope, Poetry still broken on MacOS if you're not using pyenv. The main dev is married to the idea that a system has an "active" python and when you call Poetry it should use that Python, even if it's python2 because-- as is standard-- 'python' points to python2 and 'python3' or python3.x points to python 3.

Now they did provide an 'env' command that lets you modify the environment of an already created system but because it will be python2 based by default you need to modify the .toml file to allow python 3 before you can run the env command to change it. Because a perfectly normal way to use a tool that automates/manages this stuff is to hand edit .toml files every time you create a project.

So basically if you want to use Poetry either use pyenv or setup a virtual environment / venv before running it.

Jesus christ

Coincidentally RHEL actually dropped the idea of there being an "official" choice of python2 or python3 for the system-wide python. You either have to invoke python2 or python3 directly or you can mess with a system setting that aliases "python" to point to whichever one you want, but there's no longer a default choice. This has no relevance to me at all as a dedicated environment user but I thought it was interesting, like a clear signal that they're moving toward abandoning python2 (as they should) but there's some loud contingent of dudes who they need to keep happy by making little compromises like this one. "Well I guess we just won't have a 'python' command anymore, I hope you're happy"

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

SurgicalOntologist posted:

I have used conda for what seems like a decade, never really think about if I'm using conda or pip, and have never had a problem. What symptoms of friction? Genuinely curious.

The main problem is that you should have a single source of truth for configuring your projects dependencies.

QuarkJets
Sep 8, 2008

I still remember being on the phone with one of the lead engineers at Enthought and having him explain to me that they don't support Python3 environments yet because Python2 will live eternal, and while they're working on eventually supporting Python3 they're not in a big rush cause most people probably aren't even using Python3 anyway, certainly most scientists still need Python2 cause their packages aren't even available in Python3 yet.

This conversation was in 2016 and I basically said "Do your executives ever wonder why Enthought's share of the market is so minuscule compared to Anaconda's? It's conversations like this one." I couldn't even believe my ears how obsolete this dude's info was.

Every dedicated "I will never upgrade" Python2 user I've ever met also thinks this way. That everyone else is still using Python2, that it's the Python3 users who are actually in the minority or that tiny demographics X and Y still need Python2 because their packages simply can't be ported to Python3. You can point them to any contrary poll you want and they'll just say "well you can't really trust polls they don't accurately reflect the truth", like there's a fuckin silent majority of Python2 users who are afraid that a poll is going to steal their banking information or something

e: if you started reading my post and were like "who the gently caress is Enthought" they're basically the incompetent bizarro world version of Anaconda that could have become a legit competitor as a provider of managed Python environments if they weren't so terrible

QuarkJets fucked around with this message at 20:18 on Jan 14, 2020

mr_package
Jun 13, 2000

Thermopyle posted:

Is there any reason to not being using pyenv?

Well it would work fine to not use it. You can install different Python versions side-by-side and then just call "python3.7 -m venv my_project" or "python3.5 -m venv my_project" and it would work just the same I think. Some people might find it a simpler process to do it that way, and especially might find it an advantage not to introduce yet another "python management" tool. Especially you don't want people who start installing random crap onto servers because "that's the only way I know how to do it" when they could have just setup the venv manually and installed a wheel or whatever.

edit: One advantage might be the ability to test with multiple versions, e.g. Red Hat is shipping 3.6 now I think; that means things like dataclasses or from __future__ import annotations and who knows what else won't work so if pyenv brings that to the table it is absolutely worth it.

mr_package posted:

Because a perfectly normal way to use a tool that automates/manages this stuff is to hand edit .toml files every time you create a project.
I should clarify that there may be a better way to do this e.g. from CLI; I just didn't find one.

mr_package fucked around with this message at 22:04 on Jan 14, 2020

Dominoes
Sep 20, 2007

SurgicalOntologist posted:

I have used conda for what seems like a decade, never really think about if I'm using conda or pip, and have never had a problem. What symptoms of friction? Genuinely curious.
I apologize for not being helpful here - it's been a long time since I used it (outside of some specialized uses where I didn't use it with Pip) I don't remember any deal breakers; just that it seemed like an odd use-design to have two overlapping package managers that had the potential for conflicts. Ie what happens if I install the same package in both? What if they're different versions? (I don't know the answer to these questions)

mr_package posted:

Nope, Poetry still broken on MacOS if you're not using pyenv. The main dev is married to the idea that a system has an "active" python and when you call Poetry it should use that Python, even if it's python2 because-- as is standard-- 'python' points to python2 and 'python3' or python3.x points to python 3... So basically if you want to use Poetry either use pyenv or setup a virtual environment / venv before running it.
I made the same assessment; this is why I made a sep project instead of PRing poetry; the Poetry philosophy's consistent with the historical python concept of having environments the user actively manages - which I don't think is necessary, and adds work.

It feels like Poetry's made leaps in the right direction; ie the `pyproject.toml` spec it uses has everything you need to describe a python project without venvs, but there's a mental/historical block preventing them from making the leap to abandoning the env concept.

Dominoes fucked around with this message at 22:42 on Jan 14, 2020

i vomit kittens
Apr 25, 2019


Is there some bug with Selenium I don't know about that causes it to error out when it shouldn't? I'm trying to scrape practice questions from a quiz that only displays one question a time, but at random times while running it the script will stop working for seemingly no reason. The WebDriver will find a button either to go to the next question or submit an answer, click that button, and then after the next page begins to load it will throw an error saying it was not able to find the button that it just clicked. I have no idea how to solve this other than the awful idea I had of just putting every click attempt in a try/catch block that passes on catch.

Phobeste
Apr 9, 2006

never, like, count out Touchdown Tom, man

mr_package posted:

edit: One advantage might be the ability to test with multiple versions, e.g. Red Hat is shipping 3.6 now I think; that means things like dataclasses or from __future__ import annotations and who knows what else won't work so if pyenv brings that to the table it is absolutely worth it.

You may already know this but the right tool for this is tox

SurgicalOntologist
Jun 17, 2004

Thermopyle posted:

The main problem is that you should have a single source of truth for configuring your projects dependencies.

The conda environment.yml file is great for this because you can specify pip dependencies as well. You do have to put them one level deeper in the yaml but at least it's the same file.

In fact that's exactly the reason I like conda -- to have a single source of truth. I can put not only python dependencies but also the python version itself plus system dependencies and anything else really that can be installed to the environment prefix instead of /usr/local/ or whatever.

Then pretty much every project I've done in years has the same 2-step deployment process for CI/CD:
1. Download and install conda.
2. Run conda env create

It's stupid easy.

Dominoes posted:

I apologize for not being helpful here - it's been a long time since I used it (outside of some specialized uses where I didn't use it with Pip) I don't remember any deal breakers; just that it seemed like an odd use-design to have two overlapping package managers that had the potential for conflicts. Ie what happens if I install the same package in both? What if they're different versions? (I don't know the answer to these questions)

Yeah I agree it seems weird but it typically works out. They go to the same place so it's not like you end up with two versions of something. It is possible to create weird situations but they're edge cases typically involving downgrading versions. For example if you use pip to downgrade the version of a conda package, it will work fine, but then if you want to revert this using conda by updating it will think the original version is still installed and will do nothing. That's the worst I've seen -- an update incorrectly thinking there's nothing to do. For any case where not making a mistake like this is absolutely critical I'm not changing versions with commands I'm just editing environment.yml, so I would have to downgrade a package while also moving it from one place in the file to another for this to ever happen.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

SurgicalOntologist posted:

The conda environment.yml file is great for this because you can specify pip dependencies as well. You do have to put them one level deeper in the yaml but at least it's the same file.

Right, but most other people, projects, and deployment environments do not support conda or do so as a second-class citizen so having it all in environment.yml doesn't help.

breaks
May 12, 2001

i vomit kittens posted:

Is there some bug with Selenium I don't know about that causes it to error out when it shouldn't? I'm trying to scrape practice questions from a quiz that only displays one question a time, but at random times while running it the script will stop working for seemingly no reason. The WebDriver will find a button either to go to the next question or submit an answer, click that button, and then after the next page begins to load it will throw an error saying it was not able to find the button that it just clicked. I have no idea how to solve this other than the awful idea I had of just putting every click attempt in a try/catch block that passes on catch.

It sounds likely to be a code problem and not a selenium/webdriver issue to me. It’s impossible to diagnose without more information or preferably a minimal repro example. But probably you’re inadvertently doing something that tries to use that element again or find by that locator again after the click that changes the page.

One speculative example of how this could happen in straightforward and reasonable looking code is that if the first thing you’re doing on the next page is trying to find an element using a selector that was also valid on the previous page, that command may be in flight before the page load begins, which can result in a stale element or perhaps some other error. (AFAIK that shouldn’t happen for simple links but once JS is involved that’s out the window.)

SurgicalOntologist
Jun 17, 2004

Thermopyle posted:

Right, but most other people, projects, and deployment environments do not support conda or do so as a second-class citizen so having it all in environment.yml doesn't help.

Good point, if I expect my project could be a dependency of some other project (i.e. it's a library not an application) I would use a different approach -- didn't have that in mind but yes. I use conda when I want to be able to replicate an environment exactly, which I only would bother to do for applications.

As for deployment, it's true that in some places you may have to do curl | bash on the conda install script rather than it being already available but it works well. Anyways these days I just use docker and it's as much a first-class citizen as anything else. It works great with layer caching -- only need to reinstall the dependencies if environment.yml changes.

I'm not trying to be a conda envangelist I'm just surprised when people are dismissive of it. Since I started using conda I've barely had to think about dependency management at all, always have everything specified in one file, and can reuse the same Dockerfile everywhere.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

SurgicalOntologist posted:

Good point, if I expect my project could be a dependency of some other project (i.e. it's a library not an application) I would use a different approach -- didn't have that in mind but yes. I use conda when I want to be able to replicate an environment exactly, which I only would bother to do for applications.

There are (were?) also CI and PaaS deployment solutions where conda just isn't supported or is a second-class citizen. (of course, it's been awhile since I used conda much so I'm sure the story has changed)

There are all sorts of good reasons to use conda, but if those reasons aren't applicable to your use case there are costs to using it as well. In my work, I rarely need it. It just doesn't solve any problems for me.

As I mentioned earlier, I also have gotten to where I use Docker extensively so, while in the past I might use conda from time to time, I basically never do nowadays.

i vomit kittens
Apr 25, 2019


breaks posted:

It sounds likely to be a code problem and not a selenium/webdriver issue to me. It’s impossible to diagnose without more information or preferably a minimal repro example. But probably you’re inadvertently doing something that tries to use that element again or find by that locator again after the click that changes the page.

One speculative example of how this could happen in straightforward and reasonable looking code is that if the first thing you’re doing on the next page is trying to find an element using a selector that was also valid on the previous page, that command may be in flight before the page load begins, which can result in a stale element or perhaps some other error. (AFAIK that shouldn’t happen for simple links but once JS is involved that’s out the window.)

It's just so confusing to me because of how variable it is. It will work fine for 100 questions, maybe even 300, and then just abruptly fail on one. It's also not failing trying to use an element after the button click, it's the button click itself that is throwing the error.

code:
    for x in range (0, 250):
         paragraphs = wait.until(EC.visibility_of_all_elements_located((By.ID, "para")))
        ---logic for determining which paragraphs are part of the question, answers, or neither and writing them to the appropriate place---
        answerRadio = wait.until(EC.element_to_be_clickable((By.ID, "SelectedAnswerId")))
        driver.execute_script("arguments[0].checked = true;", answerRadio)
        answerRadio.click()
        //the click is necessary because the "Show Answer" button does not become available until the focus changes.
        showAnswer = wait.until(EC.element_to_be_clickable((By.ID, "aShowAnswerCQTab")))
        showAnswer.click() *****
        time.sleep(2)
        paragraphs = wait.until(EC.presence_of_all_elements_located((By.TAG_NAME, "p")))
        //The paragraphs on the answer page do not have the class name "para" like on the question page.
        ---logic for determining which paragraph is the one that says the correct answer and writing it to the file.---
        nextQuestion = wait.until(EC.element_to_be_clickable((By.ID, "aSubmitCQTab")))
        nextQuestion.click() *****
The lines where I put ***** are where the stack traces point to the problem being. Like I said, the click does actually go through, because the page will change to either show the answer or go to the next question, but the script throws an error immediately after the fact saying that it was unable to find the button that allows it to do what it just did.

Adbot
ADBOT LOVES YOU

necrotic
Aug 2, 2005
I owe my brother big time for this!
It could be timeouts on the wait for. Not sure how the python driver works but it bit me in the past with random slow page loads. We increased the default timeout and that fixed it.

Edit: though that doesn't look to involve a full page load. Still worth a quick check.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply