alexgolec / schwab-py

Unofficial API wrapper for the Schwab HTTP API
MIT License
210 stars 49 forks source link

schwab-py works with docker base ubuntu20 ,not ubuntu22 #184

Open fatdrag0n opened 1 day ago

fatdrag0n commented 1 day ago

Please read the bug submission guidelines before submitting a bug.

Not following guidelines may result in your bug being ignored and/or closed.

Description of Bug I just dockerized my app after some efforts and it simple is based on schwab-py and basic ubuntu python base os and it install some os apps/pip packages and It works on ubuntu20 but fails on ubuntu22. Changed underlying host ubuntu to find culprit seems like it is related to the building of image container and some dependencies that fails and cross os version/pip/libaries or something more simpler than that!

Code to Reproduce I run this script where it builds my container and runs it and drop me into bash prompt and I test schwab api!

./runmsdocker.sh
docker build -t ubuntu-python .
docker run -it ubuntu-python 

it processes build of docker image

./runmsdocker.sh 
[+] Building 3.1s (16/16) FINISHED                                                                            docker:default
 => [internal] load build definition from Dockerfile                                                                    0.2s
 => => transferring dockerfile: 1.04kB                                                                                  0.0s
 => [internal] load metadata for docker.io/library/ubuntu:20.04                                                         1.2s
 => [auth] library/ubuntu:pull token for registry-1.docker.io                                                           0.0s
 => [internal] load .dockerignore                                                                                       0.2s
 => => transferring context: 2B                                                                                         0.0s
 => [internal] load build context                                                                                       0.2s
 => => transferring context: 32B                                                                                        0.0s
 => [ 1/10] FROM docker.io/library/ubuntu:20.04@sha256:8e5c4f0285ecbb4ead070431d29b576a530d3166df73ec44affc1cd27555141  0.0s
 => CACHED [ 2/10] RUN apt-get update &&     apt-get install -y     python3.9     python3.9-distutils     python3.9-ve  0.0s
 => CACHED [ 3/10] RUN ln -s /usr/bin/python3.9 /usr/bin/python                                                         0.0s
 => CACHED [ 4/10] RUN pip3 install python-dateutil                                                                     0.0s
 => CACHED [ 5/10] RUN pip3 install httpx                                                                               0.0s
 => CACHED [ 6/10] RUN pip3 install requests                                                                            0.0s
 => CACHED [ 7/10] RUN pip3 install schwab.py                                                                           0.0s
 => CACHED [ 8/10] RUN git clone https://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@github.com/fatdrag0n/marketsignal.gi  0.0s
 => CACHED [ 9/10] WORKDIR /marketsignal                                                                                0.0s
 => CACHED [10/10] COPY token.json schwab/token.json                                                                    0.0s
 => exporting to image                                                                                                  0.2s
 => => exporting layers                                                                                                 0.0s
 => => writing image sha256:35673fb117be19d03c5d105c3185a569e1a9fb4ee65428613d62861bf95e65ac                            0.1s
 => => naming to docker.io/library/ubuntu-python                                                                        0.0s

using this docker image Dockerfile

FROM ubuntu:20.04
#FROM ubuntu:22.04

# Set environment variables to avoid interactive prompts during package installation
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED=1

# Update package list and install Python, Bash, Git, and Ping utilities
RUN apt-get update && \
    apt-get install -y \
    python3.9 \
    python3.9-distutils \
    python3.9-venv \
    python3-pip \
    bash \
    iputils-ping \
    git \
    curl \
    vim \
    net-tools \
    screen \
    && apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN ln -s /usr/bin/python3.9 /usr/bin/python
#RUN pip3 install -r requirements.txt
RUN pip3 install python-dateutil
RUN pip3 install httpx
RUN pip3 install requests
RUN pip3 install schwab.py
RUN git clone https://xxxxxxxxxxxxx@github.com/fatdrag0n/marketsignal.git /marketsignal
WORKDIR /marketsignal
COPY token.json schwab/token.json
# Set the default command to bash
CMD ["bash"]
#CMD ["python3"]

IMPORTANT: Remember to anonymize your code. Be sure to replace API keys/Client IDs with placeholders. Also, never, ever share the contents of your token file.

Expected Behavior

root@067b8de62f23:/marketsignal# ./chkmktindex.py 
14/11/2024 10:17:41
S&P500: -15.08
DJ: -116.79
Nasdaq: -39.61
Russell2000: -24.83
BTC: -315.0

Actual Behavior


root@067b8de62f23:/marketsignal# ./chkmktext.py 
Traceback (most recent call last):
  File "/marketsignal/./chkmktext.py", line 32, in <module>
    from schwab import auth, debug
  File "/usr/local/lib/python3.10/dist-packages/schwab/__init__.py", line 1, in <module>
    from . import auth
  File "/usr/local/lib/python3.10/dist-packages/schwab/auth.py", line 9, in <module>
    import multiprocess
  File "/marketsignal/multiprocess.py", line 30
    def monitor_threads(symbols, time_frames, thread_status, running):
    ^^^
IndentationError: expected an indented block after function definition on line 26

**Error/Exception Log, If Applicable**```
See here to learn how to turn on debug logging: https://tda-api.readthedocs.io/en/latest/help.html```
fatdrag0n commented 1 day ago

I like the image just to be able to just install latest python with pip instead of specifying version! I see 3.9 in docker image....maybe that's the problem! I see 3.10 in output of ubuntu22 failure message!

jasonfiammetta commented 1 day ago

That would do it. If you do pip freeze I guarantee it'll show the prerelease version of schwab-py, 0.0.0a29.

176

Might just be best to delete or private those pre-release versions from pypi, a lot of people on the discord have run into this too one way or another