|
hbag posted:man Can you post your html? Generally buttons within forms will try to submit the form on click in addition to any action you tell it to do onClick as you've stated. If you give the button type="button" it won't submit the form code:
|
# ? Dec 8, 2021 05:27 |
|
|
# ? Jun 5, 2024 03:48 |
|
I'd like to get some ideas on how I would go about creating a python application that handles a fantasy football style vacation lottery draft. Any recommendations of librarys or example scripts that accomplish similar tasks? I'm not finding much available and having trouble brainstorming how to go about with the fundamentals of how the program would work. The basics I'm imagining is a list of people in a specific order. Person 1 through 50 take turns selecting a day or set of days for vacation with some limitations. There are a cap of # of vacation slots available per calendar day and the program keeps track of availability, shows a calendar with days either green, yellow, or red depending on # slots still available. Any thoughts on where I would start?
|
# ? Dec 8, 2021 15:10 |
|
I'm having a problem figuring out a regex and hopefully someone can point to my mistake. Here's the test case:code:
The code works when it's just one character: code:
|
# ? Dec 8, 2021 22:51 |
|
I think your issue is you're using [ ] instead of (). [ ] indicates a set of characters. Like [abc] matches a or b or c. So you're asking for "R or R or | or F or F" with that regex. https://docs.python.org/3/library/re.html
|
# ? Dec 8, 2021 22:59 |
|
Someone much better at regex than I should hopefully be able to come up with a better solution, but this works:Python code:
|
# ? Dec 8, 2021 23:02 |
|
Thanks to you both, I'm not great with groups and didn't realize I needed an outer group along with the inner group to return what I wanted
|
# ? Dec 8, 2021 23:07 |
|
Protocol7 posted:Someone much better at regex than I should hopefully be able to come up with a better solution, but this works: Groups are how you bound alternation in regex—there's nothing wrong with this. If the posted example is actually the full group of things they want to capture then (RR_|FF_) is more precise (since it would otherwise match X__D etc). That aside there's no reason I'm aware of to have an underscore on its own in a character set. Mr. Bubbles posted:I'd like to get some ideas on how I would go about creating a python application that handles a fantasy football style vacation lottery draft. Any recommendations of librarys or example scripts that accomplish similar tasks? I'm not finding much available and having trouble brainstorming how to go about with the fundamentals of how the program would work. I think you probably aren't getting much response to this because it's extremely open ended. Are you asking for help on figuring out what framework to use for a UI for this to run as a program on a single computer because all of these people are literally going to take turns with the same keyboard/mouse or are you trying to make a website to do this or? Wallet fucked around with this message at 23:30 on Dec 8, 2021 |
# ? Dec 8, 2021 23:26 |
|
Yeah, that's ok. Not looking for code per say, but a framework of some ideas on how to organize it. Or even an existing program that has some similar features so I can get ideas. Starting with a single program and may change to a web app in the future. It's ok if no one has ideas, I'll just start coding part by part and figure it out! For instance, one way I was thinking was having an array of days of the year, 1-365. In the array I could include data from a library like time board that contains day of week / month info in order to facilitate display in a month calendar view. Also the array would contain number of "slots" remaining. I would iterate through a loop to emulate the draft and order choice. An array of users would contain a user ID# and a list of dates they selected. When selected, the slot number would decrease by one. Something like that, but also interested in other ways to organize the program / design the methods to store this data. Mr. Bubbles fucked around with this message at 01:29 on Dec 9, 2021 |
# ? Dec 9, 2021 01:20 |
|
Mr. Bubbles posted:Something like that, but also interested in other ways to organize the program / design the methods to store this data. If the days and the users are simple objects you can assign the user objects to the slots on the days instead of just counting which will let you access the information from either end and probably make your life easier.
|
# ? Dec 9, 2021 14:18 |
|
Any suggestions for resources if I want to get proficient with Pandas? I’ve mostly been following the official documentation so far, but it seems more useful for looking up methods as opposed to actually implementing them in a smart way.
|
# ? Dec 14, 2021 10:48 |
Fruits of the sea posted:Any suggestions for resources if I want to get proficient with Pandas? I’ve mostly been following the official documentation so far, but it seems more useful for looking up methods as opposed to actually implementing them in a smart way. Just time in the trenches. Though it won’t hurt to read this blog from cover to cover - https://tomaugspurger.github.io/ - especially the Modern Pandas series.
|
|
# ? Dec 14, 2021 10:59 |
|
Following along with this video helped me immensely when I was starting out with pandas https://youtu.be/5JnMutdy6Fw
|
# ? Dec 14, 2021 13:42 |
|
Datacamp helped me with pandas quite a bit years ago. It's like free code camp style learning but it costs like $30 a month.
|
# ? Dec 14, 2021 13:54 |
|
Thanks for all the suggestions, it’ll give me something to work on over the holidays.
|
# ? Dec 14, 2021 17:39 |
|
I could use a hand figuring out where setuptools gets default configuration from. I am failing to pip install uwsgi on an Apple mac in a Python 3.9.9 venv. I have an Apple Silicon Mac that has conda installed for some projects, but others are managed with pip and venv. I am able to create a venv entirely outside of anaconda by calling a non-anaconda python executable that was installed with pyenv to create the venv, which I'm then using pip to install libraries with. The problem that I'm having for some packages is that for some reason, setuptools within the venv is trying to link against the Anaconda library path, which doesn't have arm64 libraries, like this: pre:/opt/anaconda3/lib/libz.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 It's invoking the linker with: pre:-L/Users/me/opt/anaconda3/lib
|
# ? Dec 16, 2021 00:33 |
|
When you say "installed with pyenv", could that have come from an anaconda environment? I don't know much about Mac but I know that it's *nix-y. In *nix your LD_LIBRARY_PATH dictates what libraries are visible to you. Likewise, PATH shows access to directories with executables in them. Check your LD_LIBRARY_PATH and PATH and see if you have an anaconda3 path in there. Then recursively grep for anaconda3 in the directory that holds your venv and see what comes up. Or just skip doing any of that poo poo and instead grab a mambaforge installer and create a conda environment wherever you need for whatever packages you want, abandoning whatever janky workflow has led to this situation.
|
# ? Dec 16, 2021 01:21 |
|
PSA: This is not directed at the last poster, I just want people to be aware of mamba. Stop using conda, use mamba instead.
|
# ? Dec 16, 2021 01:24 |
|
That's awesome, how did I miss mamba for so long! My team will be very pleased to have faster builds.
|
# ? Dec 16, 2021 01:37 |
|
Some of my environments mamba sets up in seconds whereas conda can't even resolve them. Coworkers will get frustrated with their environment build time and I'll be like "you used conda, what is this 2018???"
|
# ? Dec 16, 2021 03:54 |
|
Thank you friendly Python goons for introducing me to yet another tool my apparently archaic rear end hasn't even heard of yet.
|
# ? Dec 16, 2021 16:38 |
|
QuarkJets posted:When you say "installed with pyenv", could that have come from an anaconda environment? My continued debugging efforts are below, but I've got a quick question too: How do people do local devlopment of a celery application given that celery is a separate process? I've got a local devleopment start script, but this feels pretty janky and I bet there's a better way to do this: pre:#!/bin/sh export FLASK_ENV=development celery -A app.celery worker & flask run My full setup is:
To create a virtual environment, I'm directly invoking a Python version installed with pyenv like this: pre:~/.pyenv/versions/3.9.9/bin/python -m venv env I have no idea where that is coming from, but I feel like it must be coming from the Python setuptools, because if the command were run pre:*** uWSGI linking *** clang -o /Users/me/src/me/slack-deleter-pro/env/bin/uwsgi core/utils.o core/protocol.o core/socket.o core/logging.o core/master.o core/master_utils.o core/emperor.o core/notify.o core/mule.o core/subscription.o core/stats.o core/sendfile.o core/async.o core/master_checks.o core/fifo.o core/offload.o core/io.o core/static.o core/websockets.o core/spooler.o core/snmp.o core/exceptions.o core/config.o core/setup_utils.o core/clock.o core/init.o core/buffer.o core/reader.o core/writer.o core/alarm.o core/cron.o core/hooks.o core/plugins.o core/lock.o core/cache.o core/daemons.o core/errors.o core/hash.o core/master_events.o core/chunked.o core/queue.o core/event.o core/signal.o core/strings.o core/progress.o core/timebomb.o core/ini.o core/fsmon.o core/mount.o core/metrics.o core/plugins_builder.o core/sharedarea.o core/rpc.o core/gateway.o core/loop.o core/cookie.o core/querystring.o core/rb_timers.o core/transformations.o core/uwsgi.o proto/base.o proto/uwsgi.o proto/http.o proto/fastcgi.o proto/scgi.o proto/puwsgi.o core/zlib.o core/regexp.o core/routing.o core/yaml.o core/xmlconf.o core/dot_h.o core/config_py.o plugins/python/python_plugin.o plugins/python/pyutils.o plugins/python/pyloader.o plugins/python/wsgi_handlers.o plugins/python/wsgi_headers.o plugins/python/wsgi_subhandler.o plugins/python/web3_subhandler.o plugins/python/pump_subhandler.o plugins/python/gil.o plugins/python/uwsgi_pymodule.o plugins/python/profiler.o plugins/python/symimporter.o plugins/python/tracebacker.o plugins/python/raw.o plugins/gevent/gevent.o plugins/gevent/hooks.o plugins/ping/ping_plugin.o plugins/cache/cache.o plugins/nagios/nagios.o plugins/rrdtool/rrdtool.o plugins/carbon/carbon.o plugins/rpc/rpc_plugin.o plugins/corerouter/cr_common.o plugins/corerouter/cr_map.o plugins/corerouter/corerouter.o plugins/fastrouter/fastrouter.o plugins/http/http.o plugins/http/keepalive.o plugins/http/https.o plugins/http/spdy3.o plugins/signal/signal_plugin.o plugins/syslog/syslog_plugin.o plugins/rsyslog/rsyslog_plugin.o plugins/logsocket/logsocket_plugin.o plugins/router_uwsgi/router_uwsgi.o plugins/router_redirect/router_redirect.o plugins/router_basicauth/router_basicauth.o plugins/zergpool/zergpool.o plugins/redislog/redislog_plugin.o plugins/mongodblog/mongodblog_plugin.o plugins/router_rewrite/router_rewrite.o plugins/router_http/router_http.o plugins/logfile/logfile.o plugins/router_cache/router_cache.o plugins/rawrouter/rawrouter.o plugins/router_static/router_static.o plugins/sslrouter/sslrouter.o plugins/spooler/spooler_plugin.o plugins/cheaper_busyness/cheaper_busyness.o plugins/symcall/symcall_plugin.o plugins/transformation_tofile/tofile.o plugins/transformation_gzip/gzip.o plugins/transformation_chunked/chunked.o plugins/transformation_offload/offload.o plugins/router_memcached/router_memcached.o plugins/router_redis/router_redis.o plugins/router_hash/router_hash.o plugins/router_expires/expires.o plugins/router_metrics/plugin.o plugins/transformation_template/tt.o plugins/stats_pusher_socket/plugin.o -lpthread -lm -lz -L/Users/me/opt/anaconda3/lib -lpcre -lexpat -lintl -ldl -framework CoreFoundation /Users/me/.pyenv/versions/3.9.9/lib/python3.9/config-3.9-darwin/libpython3.9.a ld: warning: ignoring file /Users/me/opt/anaconda3/lib/libz.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 ld: warning: ignoring file /Users/me/opt/anaconda3/lib/libpcre.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 ld: warning: ignoring file /Users/me/opt/anaconda3/lib/libexpat.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 ld: warning: ignoring file /Users/me/opt/anaconda3/lib/libintl.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64 Undefined symbols for architecture arm64: "_XML_ErrorString", referenced from: _uwsgi_xml_config in xmlconf.o "_XML_GetCurrentLineNumber", referenced from: _uwsgi_xml_config in xmlconf.o This would be solved if anaconda would distribute arm64 libraries or universal libraries instead of x86 only, then it would be able to link against the libraries that anaconda has.
|
# ? Dec 16, 2021 17:20 |
|
Foreman, or one of the ports if you don’t want to use the ruby version, is great for running multiple processes locally easily. https://github.com/ddollar/foreman
|
# ? Dec 16, 2021 17:42 |
|
the usual python answer here tends to be supervisord, in my experience, which might also be a port of foreman, i have never checked for my personal projects i have some tasks defined in vs code for starting or bumping services, in production i just use systemd though
|
# ? Dec 16, 2021 20:06 |
|
Twerk from Home posted:I really appreciate the suggestion and am checking out Mamba, but I'm still stuck at this same failure state. Should I just give up at using pip and only use packages offered through the conda infrastructure? I'm only using pip for this one because I'm much more familiar with doing CI / deployment of web services using pip with requirements.txt. I think that you should try using mamba to create the environment instead of pyenv. Then activate the environment and use "mamba install X" or "pip install Y" to install things. You should not touch any other version of pip or conda than what exists from within your environment Or define a yaml file defining the specific packages and version requirements, and create the entire environment with "mamba env create" while specifying the yaml file. You can put a pip block in conda yaml files, anything within the block will be pip installed, everything else will be mamba installed. I think doing the above should solve this problem and let you pip install that package, but the specific problem was that pip couldn't build a wheel, right? Conda/mamba use prebuilts, so just using mamba to install whatever package you're stuck on is also something you can try. Personally I don't use pip for anything unless I absolutely have to
|
# ? Dec 16, 2021 21:04 |
|
QuarkJets posted:I think that you should try using mamba to create the environment instead of pyenv. Then activate the environment and use "mamba install X" or "pip install Y" to install things. You should not touch any other version of pip or conda than what exists from within your environment Thanks, that was actually the first thing that I tried, mamba / conda only install x86 binaries / libraries, and I was encountering another problem at runtime rather than build-time because it was trying to link conda-managed x86 binaries against system-managed arm64 libraries, which was failing too. I was using pip because pip is able to load / link arm64 binaries, libraries, and python runtimes, which conda / mamba don't seem to do at all. I'll try just using uwsgi from conda-forge again: https://anaconda.org/conda-forge/uwsgi
|
# ? Dec 16, 2021 22:57 |
|
Twerk from Home posted:Thanks, that was actually the first thing that I tried, mamba / conda only install x86 binaries / libraries, and I was encountering another problem at runtime rather than build-time because it was trying to link conda-managed x86 binaries against system-managed arm64 libraries, which was failing too. I'm not familiar with all the stuff in your OP, but if it helps, I used Miniforge to get tensorflow working on my m1, and I was able to subsequently get matplotlib and CV2 installed no problem via pip within that miniforge env, which was giving me a bunch of issues wrt linking x86 with ARM before. I followed something like this to get it going: https://betterprogramming.pub/installing-tensorflow-on-apple-m1-with-new-metal-plugin-6d3cb9cb00ca It solved so many problems that I even pip installed all my flask deps into the same venv without any trouble just to keep it simple, as I don't dev much on this thing.
|
# ? Dec 17, 2021 02:54 |
|
Does Tensorflow actually get accelerated by the M1's hardware in any way, or is utilizing the GPU and Neural Engine still a few months out?
|
# ? Dec 17, 2021 19:16 |
Protocol7 posted:Does Tensorflow actually get accelerated by the M1's hardware in any way, or is utilizing the GPU and Neural Engine still a few months out? Not out of box, but there's, for example, this.
|
|
# ? Dec 17, 2021 19:17 |
|
I have a program which basically uses multiprocessing to create a pool of workers (one per CPU core, 36 in this instance.), and each worker calls an external program via subprocess.call(), such that they run in parallel. The external program is an unholy command of the form:code:
The problem is that it runs slow, it's like the completion time for each worker (the tasks should be roughly identical in complexity.) goes up exponentially. And there's no rhyme or reason to which tasks complete fast and which take a long time: code:
code:
Python 3.8.3 on Rocky Linux 8.5, if it matters.
|
# ? Dec 17, 2021 19:51 |
|
Are all instances writing to the same output file, as described (foo.txt)? That would be a problem. Use temporary working directories to solve that. Start by wrapping this up in a concurrent.futures.ProcessPoolExecutor context manager, that's currently the proper way to implement multiple worker dispatch on a single node. It is a higher level interface for multiprocessing and is the new hotness. That's the point where you define the number of workers. Define a function that invokes your executable with subprocess.run (call is deprecated). Then map against it. Your N workers will each run the function until the argument map is exhausted. Also, make sure you're not overloading the CPU. Half of your cores are probably logical, and processor-intensive tasks can't efficiently make use of them. There is also a possibility that IO incurs a heavy penalty for simultaneous execution. Do the above changes first, then worry about this if you still see exponential overhead growth QuarkJets fucked around with this message at 20:46 on Dec 17, 2021 |
# ? Dec 17, 2021 20:40 |
|
That pattern of execution is also pretty suspicious, multiple calls to the same program may be interfering with your efforts (e.g. if the first invocation forks a new process that just sits around listening, and the listening is a little too widely scoped such that all open processes are receiving and queuing commands from all other forked processes)
|
# ? Dec 17, 2021 20:52 |
I created this structure but I have no idea what to call it or if it's even a proper thing. Can anyone help me figure out what this thing is? Obviously it's a 2d array but am I using the {} correctly with []? If so what is the distinction? I must have based this off an example but I can't seem to Google what kind of structure this is called in Python.code:
|
|
# ? Dec 17, 2021 21:04 |
|
Popete posted:I created this structure but I have no idea what to call it or if it's even a proper thing. Can anyone help me figure out what this thing is? Obviously it's a 2d array but am I using the {} correctly with []? If so what is the distinction? I must have based this off an example but I can't seem to Google what kind of structure this is called in Python. Maybe explain what you're trying to do
|
# ? Dec 17, 2021 21:09 |
|
Definitely need some more context. But at a surface level it looks like a normal dict with arrays as values which isn't the weirdest thing.
|
# ? Dec 17, 2021 21:16 |
QuarkJets posted:Maybe explain what you're trying to do I'm writing a daemon that among other things reads out the temperatures from sysfs. I'm using that structure to hold all the thermal point names I want to read as well as the over/under temp thresholds and current fault state, when an over/under temp is detected it reports a fault to a fault log on the system. I'm a relative newbie to Python and the distinction between arrays/lists/dicts etc. kinda goes over my head. So I guess my question is, what data structure is it called? What is the distinction between curly braces and square brackets and did I do that correctly? It works, I just want to know if I did it "properly". Popete fucked around with this message at 21:20 on Dec 17, 2021 |
|
# ? Dec 17, 2021 21:17 |
|
QuarkJets posted:Are all instances writing to the same output file, as described (foo.txt)? That would be a problem. Use temporary working directories to solve that. Thanks for replying! The programs separated by && all write to the same file (sequentially) but each worker thread writes to its own file. HyperThreading is in fact turned off on these machines, so one core == one real core. I’ll try the ProcessPoolExecutor.
|
# ? Dec 17, 2021 21:29 |
|
Popete posted:I'm a relative newbie to Python and the distinction between arrays/lists/dicts etc. kinda goes over my head. So the big thing about lists and dicts is they are both collection types. What this basically means is that they're containers of data. One of the most notable differences between the two is how you access a specific piece of data. In a standard list, it's index based, so you need to pass a number to access a member like so: Python code:
Python code:
Python code:
Python code:
Then, to see what sensors you have configured, it's as simple as grabbing the keys. You could even check them programatically like so: Python code:
Macichne Leainig fucked around with this message at 21:36 on Dec 17, 2021 |
# ? Dec 17, 2021 21:33 |
Protocol7 posted:Helpful post This is a great explanation thank you! I think I can improve upon it as you mentioned. I was actually using TempSensors as an IntEnum. code:
Like you showed here. Python code:
Protocol7 posted:I think what you have here - I'd call it a dictionary with lists for values - is pretty close to what you want, assuming my understanding of your problem is correct of course. That sounds correct. Basically I'm trying to use a single structure to track if a particular sensor currently has an over/under temp fault along with the threshold values and it's name. Popete fucked around with this message at 21:42 on Dec 17, 2021 |
|
# ? Dec 17, 2021 21:40 |
|
Yeah that should be fine. I'm so used to just using strings with dicts that they're kinda the default key type for me. But as long as the numbers are unique (and it looks like they are) that should work just fine I suppose you'll want to retain the string in your lists if you want to keep the sensor name, but that's a small change.
|
# ? Dec 17, 2021 21:42 |
|
|
# ? Jun 5, 2024 03:48 |
|
Yeah, for the values you could maybe use a dataclass instead of a list to help label your code better. Seems fine to me though
|
# ? Dec 17, 2021 21:49 |