Pynecone이 Reflex로 브랜드를 변경했습니다. 

해당 사이트로 들어가보니 기존 Pynecone 프로젝트를 Reflex로 Migration하는 가이드가 있어서 적용했습니다.

 

1. pip로 reflex 설치

pip install reflex

설치후 기존 설치되었던 라이브러리와 비교해봅니다.

기존 Pynecone pip list reflex 설치후 pip list
pn@ed2cb8e6e508:/reflex/biz_board$ pip list
Package            Version
------------------ ----------
anyio              3.6.2
async-timeout      4.0.2
bidict             0.22.1
certifi            2022.12.7
charset-normalizer 3.0.1
click              8.1.3
cloudpickle        2.2.1
commonmark         0.9.1
distlib            0.3.6
fastapi            0.88.0
filelock           3.9.0
greenlet           2.0.2
gunicorn           20.1.0
h11                0.14.0
httpcore           0.16.3
httpx              0.23.3
idna               3.4
numpy              1.24.1
packaging          23.1
pandas             1.5.3
pip                23.2
pipenv             2022.12.19
platformdirs       2.6.2
plotly             5.13.0
psutil             5.9.4
pydantic           1.10.2
Pygments           2.14.0
PyMySQL            1.0.2
pynecone           0.1.29
python-dateutil    2.8.2
python-engineio    4.4.1
python-multipart   0.0.5
python-socketio    5.8.0
pytz               2022.7.1
redis              4.4.2
requests           2.28.2
rfc3986            1.5.0
rich               12.6.0
setuptools         65.5.1
six                1.16.0
sniffio            1.3.0
SQLAlchemy         1.4.41
sqlalchemy2-stubs  0.0.2a32
sqlmodel           0.0.8
starlette          0.22.0
tenacity           8.1.0
typer              0.4.2
typing_extensions  4.4.0
urllib3            1.26.14
uvicorn            0.20.0
virtualenv         20.17.1
virtualenv-clone   0.5.7
watchdog           2.3.1
websockets         10.4
wheel              0.38.4
pn@ed2cb8e6e508:/reflex/biz_board$
pn@ed2cb8e6e508:/reflex/biz_board$ pip list
Package            Version
------------------ ----------
alembic            1.11.1
anyio              3.6.2
async-timeout      4.0.2
bidict             0.22.1
certifi            2022.12.7
charset-normalizer 3.0.1
click              8.1.3
cloudpickle        2.2.1
commonmark         0.9.1
distlib            0.3.6
fastapi            0.96.1 <- 0.88.0
filelock           3.9.0
greenlet           2.0.2
gunicorn           20.1.0
h11                0.14.0
httpcore           0.16.3
httpx              0.24.1 <- 0.23.3
idna               3.4
Jinja2             3.1.2
Mako               1.2.4
markdown-it-py     3.0.0
MarkupSafe         2.1.3
mdurl              0.1.2
numpy              1.24.1
packaging          23.1
pandas             1.5.3
pip                23.2
pipenv             2022.12.19
platformdirs       2.6.2
plotly             5.13.0
psutil             5.9.4
pydantic           1.10.2
Pygments           2.14.0
PyMySQL            1.0.2
pynecone           0.1.29
python-dateutil    2.8.2
python-dotenv      0.13.0
python-engineio    4.4.1
python-multipart   0.0.5
python-socketio    5.8.0
pytz               2022.7.1
redis              4.4.2
reflex             0.2.1
requests           2.28.2
rfc3986            1.5.0
rich               13.4.2
setuptools         65.5.1
six                1.16.0
sniffio            1.3.0
SQLAlchemy         1.4.41
sqlalchemy2-stubs  0.0.2a32
sqlmodel           0.0.8
starlette          0.27.0
starlette-admin    0.9.0
tenacity           8.1.0
typer              0.4.2
typing_extensions  4.4.0
urllib3            1.26.14
uvicorn            0.20.0
virtualenv         20.17.1
virtualenv-clone   0.5.7
watchdog           2.3.1
watchfiles         0.19.0
websockets         10.4
wheel              0.38.4
pn@ed2cb8e6e508:/reflex/biz_board$

2. 기존 프로젝트에서 reflex init

pn@ed2cb8e6e508:/reflex/biz_board$ reflex init
────────────────────────────── Initializing biz_board ──────────────────────────────
[14:08:05] Initializing the web directory.                              console.py:30
Pynecone project detected. Automatically upgrade to Reflex? [y/n]: y
Renaming pcconfig.py to rxconfig.py
[14:08:16] Finished Initializing: biz_board                             console.py:30
pn@ed2cb8e6e508:/reflex/biz_board$

reflex init를 수행하면 해당 프로젝트의 모든 소스 파일들에서 참조하는 'import pynecone as pc' 가  'import reflex as rx'로 자동 변환됩니다. 

 

또한 pcconfig.py 파일이 위치하는 경로에  reflex init 파일이 자동으로 생성됩니다.

import reflex as rx

config = rx.Config(
    app_name="biz_board",
    api_url="http://서비스IP:8000",
    db_url="sqlite:///reflex.db",
    env=rx.Env.DEV,
)

 

3. 사용중인 pynecone.db 를 reflex db init

기존 pynecone.db 파일을 reflex.db 파일로 이름을 변경합니다. 그다음 reflex db init를 수행하면 새로운 reflex.db로 초기화를 해줍니다.

pn@ed2cb8e6e508:/reflex/biz_board$ reflex db init
──────────────────── [ State(rx.State) ] ────────────────────────
──────────────────── [ AuthState(State) ] ───────────────────────
──────────────────── [ ServiceState(State) ] ────────────────────
[biz_sqldata] get_biz_monitor_svc service_list len: 35
──────────────────── [ ServerState(State) ] ─────────────────────

[biz_servers] get_server_data(blank,)
Compiling:  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 4/4 0:00:00
  Creating directory '/reflex/biz_board/alembic' ...  done
  Creating directory '/reflex/biz_board/alembic/versions' ...  done
  Generating /reflex/biz_board/alembic/README ...  done
  Generating /reflex/biz_board/alembic/script.py.mako ...  done
  Generating /reflex/biz_board/alembic.ini ...  done
  Generating /reflex/biz_board/alembic/env.py ...  done
  Please edit configuration/connection/logging settings in '/reflex/biz_board/alembic.ini' before proceeding.
pn@ed2cb8e6e508:/reflex/biz_board$

 

이후 구동하면 기존과 동일하게 구동됩니다.

 

이후에는 reflex로 추가되는 작업을 올려야겠습니다.

+ Recent posts