Reload code location not working #24560
-
|
Hello community 👋 I'd like some insights into what could be wrong with my local Dagster setup. When I try to reload the code location, it doesn't work, even though I can see in the logs that the modules are being loaded again. I have a local docker image running Dagster. Before I was using the @repository decorator, the reload always worked fine. Recently, I migrated the code to use Definitions, and the issue started. Here are some of my files:
FROM base_dagster_image
RUN mkdir -p /opt/dagster/app
WORKDIR /opt/dagster/app
COPY . .
RUN pip install -r requirements.txt
EXPOSE 4000
CMD ["dagster", "api", "grpc", "-h", "0.0.0.0", "-p", "4000", "-w", "workspace.yaml"]
#CMD ["dagster", "code-server", "start", "-h", "0.0.0.0", "-p", "4000", "-w", "workspace.yaml"]I have tried with code-server and grpc
load_from:
- python_file:
relative_path: "definitions.py"
attribute: "batch"
location_name: "batch"
version: '3.4'
services:
dagster:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
command: >
bash -c "dagster-webserver -h 0.0.0.0 -w /opt/dagster/app/workspace.yaml"
working_dir: /opt/dagster/app/
volumes:
- ./:/opt/dagster/app
environment:
- DAGSTER_HOME=/tmpBased on the logs, I know that my The
from dagster import Definitions, AssetsDefinition, ScheduleDefinition, SensorDefinition, JobDefinition
from dagster._core.definitions.partitioned_schedule import UnresolvedPartitionedAssetScheduleDefinition
from common.utils import recursively_find_instances
dagster_assets = recursively_find_instances(root="batch", types=(AssetsDefinition,))
dagster_schedules = recursively_find_instances(root="batch", types=(ScheduleDefinition,
UnresolvedPartitionedAssetScheduleDefinition))
dagster_sensors = recursively_find_instances(root="batch", types=(SensorDefinition,))
dagster_jobs = recursively_find_instances(root="batch", types=(JobDefinition,))
batch = Definitions(
assets=dagster_assets,
schedules=dagster_schedules,
sensors=dagster_sensors,
jobs=dagster_jobs
# resources={...}
)Update: To provide more context, as I continue debugging what may be the issue. The hot reloading for the container is working. Any insights or recommendations would be really appreciated. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
|
Edit: Fixed the problem with |
Beta Was this translation helpful? Give feedback.
-
|
Can you please @kennycontreras link here a simple github project for this auto reload inside docker ? I tried your solution, but it does not want to work |
Beta Was this translation helpful? Give feedback.
-
|
@C-Loftus @jessebrowning @kennycontreras I checked your code @C-Loftus .. Inside entrypoint.sh, you are using this code " set -x if [ "$DAGSTER_DEBUG" = "true" ]; then to refresh code, bussinnes logic inside Dagster. If you are in Debug mode, then you are using "dagster dev" .. My use case is that Docker container should always run .. It would not be good to restart Docker container to apply, accept code change, busines logic When I use this " dagster code-server start -h 0.0.0.0 -p 4000 -m userCode.main " ,, then I always need first to restart docker container, then I need to start again docker container to see the change in code, in busines logic. Also checked the files with "cat" inside running docker container .. The code change, business logic is visible, applied inside this file, but for some reason it does not to refresh, change without restart of the docker container. |
Beta Was this translation helpful? Give feedback.

Edit: Fixed the problem with
importlib.reload(module_name)and it's working perfectly.