github-actions[bot] commented on code in PR #40761:
URL: https://github.com/apache/beam/pull/40761#discussion_r4364945517


##########
website/www/site/content/en/documentation/sdks/python-pipeline-dependencies.md:
##########
@@ -109,10 +109,11 @@ Staged files are downloaded onto the worker:
 
       import my_module
 
-* **Data or configuration files**: If you staged non-Python files (such as a 
JSON config), they are downloaded to the staged files directory. You can locate 
this directory on the worker by reading the `SEMI_PERSISTENT_DIRECTORY` 
environment variable, or look for `/tmp/staged` which is the default location 
for staged files on containerized runners:
+* **Data or configuration files**: If you staged non-Python files (such as a 
JSON config), they are downloaded to the `$SEMI_PERSISTENT_DIRECTORY/staged` 
directory. The full path depends on the runner, so build it from the 
environment variable instead of hardcoding it.
 
       import os
-      staged_dir = os.environ.get('SEMI_PERSISTENT_DIRECTORY', '/tmp/staged')
+      staged_dir = os.path.join(
+          os.environ.get('SEMI_PERSISTENT_DIRECTORY'), 'staged')

Review Comment:
   **🟢 Low**: If `SEMI_PERSISTENT_DIRECTORY` is not set (e.g., during local 
execution or testing with `DirectRunner`), 
`os.environ.get('SEMI_PERSISTENT_DIRECTORY')` returns `None`, which causes 
`os.path.join(None, 'staged')` to fail with a `TypeError: expected str, bytes 
or os.PathLike object, not NoneType`. Using 
`os.environ['SEMI_PERSISTENT_DIRECTORY']` (to fail explicitly with `KeyError` 
if unset) or providing a default fallback (such as `'/tmp'`) would be safer.
   
   ```suggestion
             os.environ.get('SEMI_PERSISTENT_DIRECTORY', '/tmp'), 'staged')
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to