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
Hed
Mar 31, 2004

Fun Shoe

The March Hare posted:

Very good move.

To whoever was asking why it wasn't in stdlib earlier: https://speakerdeck.com/kennethreitz/python-requests-and-the-standard-library

Thanks for that. I figured it would boil down to "putting in the stdlib involves losing agility". I get it.

Adbot
ADBOT LOVES YOU

Hed
Mar 31, 2004

Fun Shoe

porksmash posted:

Does anyone have experience mirroring PyPi? My work is about to shut off all internet access to internal servers as a security measure, and are working on setting up internal package mirrors for everything we use. I think they're more concerned about the internet connection than malicious packages, which is lucky for me. I'm leaning towards a caching PyPi proxy server like devpi-server rather than an actual mirror of the entire index.

You’ve got the right idea. With some of the other methods package searching from pip was wonky, but devpi works pretty well for us.

Hed
Mar 31, 2004

Fun Shoe

Thermopyle posted:

Kenneth Reitz did a talk on Pipenv that might be useful for anyone wondering why they should use Pipenv.

https://www.youtube.com/watch?v=GBQAKldqgZs

Thanks, this was neat and I'll give it a shot.

Hed
Mar 31, 2004

Fun Shoe

Thermopyle posted:

I stumbled across this site which I thought people might find useful.

It's basically an in-depth guide or tutorial of what looks like the whole itertools module. So, if you're like me and ever see someone using itertools and think "drat, I should use itertools more", maybe this will help.

Thanks, I was dorking around this weekend and used itertools and kind of thought the same "why don't I reach for this more often".

Hed
Mar 31, 2004

Fun Shoe

The Fool posted:

At work in am receiving a backup of an Sql database, but I will not be getting control of any of the existing infrastructure or front end.

I was thinking about throwing up a quick and dirty Django front end, but have no idea how to set up the orm to handle an existing database.

Is there an accepted best practice? Should I just build out a new table structure that I can import the data into, or is there a better way?

You want Django introspection. It will build out the models based on the existing table structure.

Hed
Mar 31, 2004

Fun Shoe
I would recommend backing up a bit. Look at the original histogram for huge spikes or cumulative transfer function of pixel intensity--does it have any discontinuities? If so then histogram linearization is going to have some interesting effects.

Hed
Mar 31, 2004

Fun Shoe
Does PyCharm still include the features from Webstorm that are good? In other words if I want to dork around with React and Django is it PyCharm or get the full Monty?

I tried PyCharm back in 2011 for purely Python and didn’t stick with it but I have a different flow now and I’m interested.

Hed
Mar 31, 2004

Fun Shoe

I enjoyed this.

Hed
Mar 31, 2004

Fun Shoe
The walrus operator looks neat but I'll have to practice with it to see where it's good and more importantly where it might impair readability.

Hed
Mar 31, 2004

Fun Shoe

Malcolm XML posted:

What's people's favorite config parser that allows for env var override?

I'm spoiled by spring boots config engine which is p nice for yaml

This isn't exactly what you're talking about but for Django configs I like this one: https://github.com/joke2k/django-environ so I would look at one of the ones it is based on like envparse

Hed
Mar 31, 2004

Fun Shoe

Thermopyle posted:

kebab-case

Thank you.

Hed
Mar 31, 2004

Fun Shoe

punished milkman posted:

i feel like a dumbass calling wsgi 'whiskey'

I usually just say whizz-ghee


Like this guy!

Hed
Mar 31, 2004

Fun Shoe
Random question--is there a way to turn off PyCharm's duplicated code fragment warning just in tests? When I'm in a test_*.py file, I'd want different rules.

There's usually a bit of boilerplate in my testing code that I want to explicitly repeat. I know I could suppress but no guarantees everyone is using PyCharm with my settings.

Hed
Mar 31, 2004

Fun Shoe
Thanks all, I'm going to annotate with the noinspect on the few test classes where I'm repeating myself. I like the fixture idea but this hasn't swollen to enough tests now to warrant that, and I've gotten in trouble making my tests too complex in the past :)

Hed
Mar 31, 2004

Fun Shoe
I'm trying to share some state (less than 1 KB of tabular data, could easily be a CSV or list of dicts) between two types of Python processes running on the same system. This would be one-to-many... one process writes the state, a handful of separate ones will read it. Any ideas for how to sync between them? I don't control spawning the reader processes and they aren't run by the same user, so it exceeds my normal use of pipes/queues. I could probably use a file but how to ensure the file is flushed and fully written to disk for the helper to read? I guess I could use a specific file terminator and only have the reader update internal copy of state when it sees that. Similar file access and concurrency issues between sqlite or something.


This seems like a problem that is reasonably common yet in a spot where standing up Redis server seems like overkill. Does anyone have any pointers in a specific direction?

Hed
Mar 31, 2004

Fun Shoe
Can you talk about your Zappa experience? I’m curious about using it for a Django problem but last I looked the maintainer had kind of noped out from appearances.

Hed
Mar 31, 2004

Fun Shoe
How can I fire off a subprocess, move on with execution, and have a callback or do something small post-execution?

I have a bunch of finite state machines that I go through and update every second in the main program loop. Sometimes the FSMs, which are python objects, run a function that does a subprocess call out to a system binary that isn't computationally expensive but can easily take several seconds to complete waiting on a response. This sucks and blocks things up. Right now that blocking call is in a subprocess.run(). I've looked at subprocess.Popen() but it's kind of a fire and forget... I guess I could Popen, then track state and see when that is done and if it had the desired effect, but I feel like I'm missing something more obvious.

Something that allowed me to fire off a subprocess and do a callback or change a flag later so I can keep the main loop going would be awesome. I've looked at asyncio and Popen like I mentioned but I feel like I'm missing something obvious in the std lib.

Bruegels Fuckbooks posted:

I'd just use mmap for this - memory mapped files generally work well for this use case.

I forgot to respond to this but thank you--this worked splendidly for what was essentially sending over a sequence of integers.

Hed
Mar 31, 2004

Fun Shoe
Do you any recommendations of alternatives to scrapy?

The problem I'm trying to solve is I built out one scrapy workflow that goes on a task queue and given Twisted reactor and the threading/singleton stuff I've run in to, it's just obvious I am really trying to "get around" a very opinionated framework. If this means I need to learn it better I'm willing to, but at this point I'm ready to consider my current implementation a throwaway prototype if there's something else.

My requirements would be just basic HTTP scraping, selection on XPaths, populating/POSTing form data, with the ability to fire up Selenium if I need to. I am typically saving entire documents instead of snippets.

Hed
Mar 31, 2004

Fun Shoe
Yep, I use ‘em now even for some relatively simple pure python programs. Controlling the input (it’s actually easier to muck with ports) and output (easy to use logging with stdout and have the log shipper be external to the program).

Hed
Mar 31, 2004

Fun Shoe
Isn’t cryptography the one that switched to linking against rusttls recently?

May not be a big deal depending on your environment but something to keep in mind.

Also, agreed re: computers.

Hed
Mar 31, 2004

Fun Shoe

Loezi posted:

I use isort followed by black followed by flake8 as my pre-commit hook and it's great.

Cheers. I never knew about isort

Hed
Mar 31, 2004

Fun Shoe
Maybe hack away at this one https://pypi.org/project/module-graph/#description and analyze the graph edges without using graphviz?

Hed
Mar 31, 2004

Fun Shoe
It’s been a while but I remember Violent Python looking like a fun read. You can redo the TCP attack that made Mitnick famous, etc.

Hed
Mar 31, 2004

Fun Shoe
Wow this caused me to look at 3.10 and the structural pattern matching looks neat.

Coming from doing a bit of Rust lately the lack of having to always declare a catch-all makes me nervous but could lead to some “interesting” uses.

Hed
Mar 31, 2004

Fun Shoe
Ok I'm messing about with a monorepo for microservices and really trying to get the hang of it both with PyCharm and other IDEs.

Here's a contrived example:

pre:
.
├── applications
│   └── app1
│       └── independpentjob1
│           ├── requirements.txt
│           ├── independentjob1.Dockerfile
│           ├── independentjob1.py
│           └── tests
│               └── test_independentjob1.py
└── services
I really want high separation for these things so that I can run the interpreter that comes from dockerfile for independentjob1 and run/debug/test that as my interpreter when I'm working in that folder. Do I need to do subprojects here? I looked at the IDE docs and it seems pretty much 1 IDEA Project == 1 Interpreter.

Hed
Mar 31, 2004

Fun Shoe

cinci zoo sniper posted:

I’m not sure I understand your idea fully, but PyCharm supports arbitrary number of interpreters per project, and you can have file-level run configurations (arbitrary number of those per file). In “global” mode, e.g., for the purposes of terminal or naive executions of code, it supports only 1 interpreter being considered active at a time.

I'm not sure I understand my idea fully either. Someone on my team suggested using k8s for a new project and I'm trying to figure out how this could work. At the end of the day, KISS with a monolith has a ton of runway, or I could go whole hog and just do everything with FaaS and get nearly the same thing. Still, trying this on.

I was able to figure out how to add additional interpreters that weren't project default (it's been a while) and that part is working just fine. I'll figure out if I can be smarter than "global" mode next. Thanks!

Hed
Mar 31, 2004

Fun Shoe
I've got a Django site that wants to run tasks and I could use celery/redis-queue/whatever but these jobs are calling containers that are also Python but don't know about Django. So I want to dispatch a task from Django to one of these artifacts and give it configuration. Need something to spawn these (could be containers, could be FaaS) and then when they're done, report back with status and data. Logging would also be great.

Does anyone have strategies for this? I feel like I'm circling around something but need a topic keyword to research.

Hed
Mar 31, 2004

Fun Shoe

cinci zoo sniper posted:

I’m sorry for not being too helpful here as this goes way past my preferred amount of community tech support, but k8s is just a deployment option, one paired well with containerised development environment. If this is not a horizontally scaled service, and a micro service mesh instead (which it sounds it is, as you care about having a zoo of interpreters), you should just do one repo per service and avoid inflicting upon yourself Google problems for no clear reason.

Also just wanted to say thanks, this was definitely the way and now I have new problems (see above) but progressing well. Right now decoupling the system of record from the workers is an annoying price to pay but it will pay off as the other services continue to expand.

Hed
Mar 31, 2004

Fun Shoe
Sure! These tasks call a job to go scrape a forum, or thread, or threadpage. So the container would start up, read configuration (from injected environment, injected config file, http call??), then use that to call functions in the container, do the work, then eventually the work needs to go to S3, and status needs to get back to the Django site somehow. Logs can go to anywhere, I’d just like to be able to look at them when things go wrong.

Hed
Mar 31, 2004

Fun Shoe
This is probably premature optimization but the issue I feel with Lambda is that for scrapers that pause/wait to be nice, it’s a lot of milliseconds Nooping whereas if I run it on my hardware I get the benefits of statistical multiplexing. Writing that out though it’s probably something to worry about another day.

Still, as far as having tasks get serialized parameters in and report back I’m looking for patterns or best practices. Something like Two Scoops that has a bunch of good patterns is pretty much “sometimes we use Lambda but it’s hard to debug” and that’s it.

Hed
Mar 31, 2004

Fun Shoe
Thanks all for the help.

CarForumPoster posted:

I still say +1 for AWS Lambda. If you need to not pay for the wait time, AWS step functions may be something you want, this would let you create a list of scrapes to do that limits concurrency and can wait. If youre behind a login just pass the cookie. Not sure what Two Scoops is.

Debugging in development with Lambdas is pretty easy if you're using the SAM CLI because you can have a docker container that behaves "just like" the deployed environment. You can time.sleep(900) and CLI in, access the python REPL, etc. Debugging in prod is another story. IDK what best practices are but I use a watchdog to fetch logs at an interval and put them where I want.

Also IME getting Celery/Redis working with my Django or Flask apps has ALWAYS been plagued by gotchas for me. With a lambda function deployed as a docker container via SAM CLI I can ship a big rear end 3GB docker image with my binaries and poo poo all built in and it JUST WORKSTM

So do you have the task just do an HTTP callback into Django/Flask with results? If that fails does it just repeat the work?


cinci zoo sniper posted:

For your job configuration just have like a pydantic data class that gets serialised to JSON via dictionaries. The configuration should include both application tasks and logistics around logging, storage, and responses.

That makes sense, I've been using the schnizz out of data classes -> JSON for the scraping results anyway so this is a natural extension. Pydantic looks great.

Hed fucked around with this message at 21:55 on Feb 10, 2022

Hed
Mar 31, 2004

Fun Shoe
I feel like you could just use or override some stuff in telnetlib in the std lib.

cinci zoo sniper posted:

I think it's safe to bet that 99% of Python developers have never had to touch something as low level as a socket.

Probably true. I’ve done a bunch of socket programming in Python to get the FSM and primitives right. Used to maintain a ton of line-oriented query servers that replaced some PERL ones, though.

Hed
Mar 31, 2004

Fun Shoe
There was a video on type hints in the past couple of years where some popular library went through their rollout of it with MyPy and other type checkers. One of their big takeaways was that it not only made the code base easier to run through but it caught some subtle bugs that they didn't otherwise cover in unit tests.

Does anyone know what this talk was? I thought it was about the requests library or something, but I can't find it.

Hed
Mar 31, 2004

Fun Shoe
Curious if anyone has recs for parsing libraries that could make the job of what appears to be fixed format column text parsing easier. I would typically just use a big ol' pile of regex and build up things, but maybe there's a better way.

An issue I see with my classic approach is when the tokens collide, like the "WeightPrice" columns below where the values spill into each other with zero spaces.


Two example files below:


pre:
CME FEEDER CATTLE INDEX CALCULATION
Tue, 01/04/22
             1/4/2022         Medium & Large    Medium & Large    Medium & Large    Medium & Large    Medium & Large    Medium & Large    Medium & Large    Medium & Large                                                              .
             TUESDAY          #1 Steers         #1 Steers         #1 Steers         #1 Steers         #1-2 Steers       #1-2 Steers       #1-2 Steers       #1-2 Steers                           Weighted                  Weighted
                              700 -749 lbs      750 - 799 lbs     800 - 849 lbs     850 - 899 lbs     700 -749 lbs      750 - 799 lbs     800 - 849 lbs     850 - 899 lbs      Total    Total      Average       Total      Average
Sale DatSale Name         Stat Head WeightPrice  Head WeightPrice  Head WeightPrice  Head WeightPrice  Head WeightPrice  Head WeightPrice  Head WeightPrice  Head WeightPrice  Head     Weight     Weight        Price       Price
 1/4/22      CLARINDA      IA  197   724  163.17 145   777  159.34 194   820  157.51 239   879  158.71  26   743  153.85  0     0    0.00   0     0    0.00   26   894  144.97  827     667016     806.55     105965055.2    158.86
 1/4/22        CUBA        MO   30  707.33160.30  31  762.61157.86  3    817  155.50  3    862  152.50  3    703  150.00  0     0    0.00   0     0    0.00   0     0    0.00   70    52006.9989   742.96     8225327.146    158.16
 1/4/22       GORDON       NE  221   726  169.29 239   764  163.89  0     0    0.00   8    881  150.50  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   468     350090     748.06     58148285.78    166.10
 1/4/22      IMPERIAL      NE  125   726  167.54 137   776  161.75  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   262     197062     752.15      32400221      164.42
 1/4/22      JACKSON       MO   30   730  162.51  0     0    0.00   3    828  139.00  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   33      24384      738.91       3904245      160.12
 1/4/22     KINGSVILLE     MO  232  730.56167.41 340   769  162.54 216  839.5 164.93  14   852  155.00  22   724  153.79  63   757  166.00  0     0    0.00   14   878  145.25  901   700123.008   777.05     114779255.7    163.94
 1/4/22      LA JUNTA      CO   87   740  164.60  15   780  155.00 107   835  153.00  58   850  156.00  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   267     214725     804.21      33771033      157.28
 1/4/22       MACON        MO  113   725  167.99  28   769  163.82  0     0    0.00   0     0    0.00   20   732  148.56  12   795  142.00  0     0    0.00   0     0    0.00   173     127637     737.79     20819551.39    163.12
 1/4/22     MCALESTER      OK   11   720  148.03  5    772  145.42  2    828  129.51  2    873  122.96  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   20      15182      759.10     2162875.52     142.46
 1/4/22      RIVERTON      WY  370   715  163.02  0     0    0.00   0     0    0.00   0     0    0.00   6    718  146.50  0     0    0.00   0     0    0.00   0     0    0.00   376     268858     715.05      43758063      162.76
 1/4/22       SALINA       KS  188   718  169.77 265  761.54171.43 219   825  164.63  73   880  154.44  55   727  150.20 118   779  158.09  0     0    0.00   42   887  146.44  960   750867.994   782.15     123171847.4    164.04
 1/4/22     UNIONVILLE     MO   83   745  159.55  24   755  166.25  0     0    0.00  372   868  161.16  0     0    0.00   11   766  146.72  4    815  145.00  0     0    0.00   494     414537     839.14     66625106.33    160.72
 1/4/22    WEST PLAINS     MO  194   719  160.60 118  769.66160.56  80   815  156.46  67   861  156.53 111   727  155.24  90   788  154.03  91   835  152.13  5    851  145.00  756   585049.998   773.88     91842167.94    156.98
 1/4/22     WILDORADO      TX   13   727  160.50  55   784  157.75  91  816.29156.39  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   159  126853.9997   797.82     19935953.55    157.16
 1/4/22    DAILY TOTALS       //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 5766  4494392.999     779     725508987.84    161.43
 1/4/22  SEVEN-DAY TOTALS     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 20007 15831316.03     791      2566732040     162.13
                              BLANK CELLS INDICATE THAT A SALE WAS NOT HELD OR A WEIGHTED AVERAGE REPORT WAS NOT ISSUED     lower case indicates special sale
                                                                                                                                                                                                              Net Change     -0.22

                                                                                                                                                                                                            REPORTED INDEX   162.13

                                                                                                                                                                                                            REPORTED CHANGE  -0.22
pre:
CME FEEDER CATTLE INDEX CALCULATION
Fri, 08/25/17
            8/25/2017         Medium & Large    Medium & Large    Medium & Large    Medium & Large    Medium & Large    Medium & Large    Medium & Large    Medium & Large                                                              .
              FRIDAY          #1 Steers         #1 Steers         #1 Steers         #1 Steers         #1-2 Steers       #1-2 Steers       #1-2 Steers       #1-2 Steers                           Weighted                  Weighted
                              700 -749 lbs      750 - 799 lbs     800 - 849 lbs     850 - 899 lbs     700 -749 lbs      750 - 799 lbs     800 - 849 lbs     850 - 899 lbs      Total    Total      Average       Total      Average
Sale DatSale Location     Stat Head WeightPrice  Head WeightPrice  Head WeightPrice  Head WeightPrice  Head WeightPrice  Head WeightPrice  Head WeightPrice  Head WeightPrice  Head     Weight     Weight        Price       Price
8/25/17       BELEN        NM   3    703  136.33  2    772  125.51  0     0    0.00   0     0    0.00   4    720  136.74  4    791  132.50  0     0    0.00   0     0    0.00   13       9697        746      1294348.61     133.48
8/25/17   BOWLING GREEN    MO   39   741  145.85  23   768  140.79  7    839  136.50  0     0    0.00   6    732  140.49  11   779  134.78  0     0    0.00   0     0    0.00   86      65397        760      9275460.11     141.83
8/25/17       BRUSH        CO                                                                                                                                                    0        0           0            0          0.00
8/25/17      BURWELL       NE   12   723  151.34  6    780  143.00  0     0    0.00   16   887  139.77  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   34      27548        810      3965881.68     143.96
8/25/17  COLORADO DIRECT   CO   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00    0        0           0            0          0.00
8/25/17      CRAWFORD      NE   36   737  156.10  0     0    0.00   19   837  148.00 108   883  149.25  15   712  153.00  0     0    0.00   0     0    0.00   0     0    0.00   178     148479       834      22362406.2     150.61
8/25/17      CRESTON       IA                                                                                                                                                    0        0           0            0          0.00
8/25/17       DUNLAP       IA                                                                                                                                                    0        0           0            0          0.00
8/25/17     FT. PIERRE     SD                                                                                                                                                    0        0           0            0          0.00
8/25/17      HERREID       SD                                                                                                                                                    0        0           0            0          0.00
8/25/17    IOWA DIRECT     IA   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00    0        0           0            0          0.00
8/25/17   KANSAS DIRECT    KS   0     0    0.00  284   775  144.00 576   828  138.59 195   850  137.50  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00  1055     862778       818      120582476.5    139.76
8/25/17     KNOXVILLE      IA                                                                                                                                                    0        0           0            0          0.00
8/25/17     LEXINGTON      NE                                                                                                                                                    0        0           0            0          0.00
8/25/17   MONTANA DIRECT   MT   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00    0        0           0            0          0.00
8/25/17 NEW MEXICO DIRECT  NM   0     0    0.00  124   775  140.00 290   825  136.80 165   875  134.00  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   579     479725       829       65529650      136.60
8/25/17  OKLAHOMA DIRECT   OK   70   700  146.50 585   750  141.60  0     0    0.00   0     0    0.00   0     0    0.00   62   776  138.50 220   840  137.50  0     0    0.00   937     720662       769       101379012     140.67
8/25/17    sioux center    ia   0     0    0.00   4    791  121.00  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00    4       3164        791        382844       121.00
8/25/17 SOUTH DAKOTA DIREC SD   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00    0        0           0            0          0.00
8/25/17 SUPERIOR VIDEO (SC S   298   710  152.07 663   765  146.05 798   810  141.79 120   875  140.50  68   710  140.00  67   750  135.00 417   805  140.28 393   850  137.25 2824    2238420       793      319134724.9    142.57
8/25/17 SUPERIOR VIDEO (NC N    0     0    0.00  1088  775  144.75 174   839  142.54  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00  1262     989186       784      142862044.4    144.42
8/25/17    TEXAS DIRECT    TX  616   723  142.00 328   773  139.56 247   801  138.96 223   860  131.00 207   722  144.09 895   774  135.23 362   800  134.39  58   850  134.35 2936    2269623       773      311998359.5    137.47
8/25/17 TORRINGTON LIVESTO WY                                                                                                                                                    0        0           0            0          0.00
8/25/17    WY-NE DIRECT    N    0     0    0.00   0     0    0.00   0     0    0.00  400   875  148.42  0     0    0.00   0     0    0.00   0     0    0.00   0     0    0.00   400     350000       875       51947000      148.42
8/25/17    DAILY TOTALS       //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 10308   8164679       792     1150714207.93   140.94
8/25/17  SEVEN-DAY TOTALS     //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 20625   16503832      800     2353826694.67   142.62
                              BLANK CELLS INDICATE THAT A SALE WAS NOT HELD OR A WEIGHTED AVERAGE REPORT WAS NOT ISSUED     lower case indicates special sale
                              Feeder Cattle Index totals for Friday, August 25, 2017 were updated due to a revised report received from Belen, New Mexico                                                     Net Change     -0.62

                                                                                                                                                                                                            REPORTED INDEX   142.62

                                                                                                                                                                                                            REPORTED CHANGE  -0.62

Hed
Mar 31, 2004

Fun Shoe
Ran into this one when I was running through test cases too quickly, and immediately assumed the function where I was building out the Decimal was wrong.

It turns out, calling Decimal() on the string was the right way, and in my tests I wrote it the way at the bottom! Always read your Expected vs. Actual to determine where the problem is :)

Python code:
>>> Decimal('920')
Decimal('920')
>>> Decimal('920') / Decimal(100)
Decimal('9.2')   # wtf it's right in the interpreter?
>>> Decimal(9.20)
Decimal('9.199999999999999289457264239899814128875732421875')     # oh god drat it

Hed
Mar 31, 2004

Fun Shoe
Pretty sure there was a good post about it in the thread… but might have been from like 2012

Hed
Mar 31, 2004

Fun Shoe

Slimchandi posted:

Anyone have any experience of using Dagster they could share here? Moving to a new place in the next couple months and they need some decent ETL tooling putting in place. My current place was always promising Airflow, but never materialised, so we just stuck with a list of python files and notebooks :)

Any reason why I should be considering Airflow over something more modern like Dagster / Prefect? The functionality seems pretty great.

I don't have anything to add but would love an answer to this too. The data science thread might be a better place for it, I've asked stuff like this before but it's kind of adjacent to a lot of things.

Hed
Mar 31, 2004

Fun Shoe
I love pytest so freaking much. For some smaller internal packages I feel like it's a big dependency to add. Do you have any examples (e.g. good packages) that handle a "production distribution" but still have tests available if you want it with optional dependencies?

Hed
Mar 31, 2004

Fun Shoe
Thanks all, I have only done a setup.py a long time ago and as I understood things have changed.

Adbot
ADBOT LOVES YOU

Hed
Mar 31, 2004

Fun Shoe

Windows 98 posted:

I like how lightweight Flask is. It's nice to leverage the werzeug routes, and SQLAlchemy. I am not really opposed to Django. I just haven't ever used it. I used to work a lot in Laravel when I was coding with PHP and was a big fan. I only switched to Python because of the job I got hired for a few years ago. We have our own ERP framework we use at work, so the actual pressing need to learn Flask or Django was never there.. So all my Python experience outside of actual work has been side projects and stuff for fun. I picked Flask because it was recommended as the most lightweight and non invasive framework, and it seems to be correct. I also like how theres a lot of little Flask specific packages floating out there.

I probably should check out Django, you're right. There is a certain amount of joy I get working on reinventing the wheel a bit, and doing it my special way that I wrote myself.

Wait, there’s a Python ERP framework?

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