Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set location for meda files on webserver #108

Open
mikemhenry opened this issue Sep 14, 2021 · 1 comment
Open

Set location for meda files on webserver #108

mikemhenry opened this issue Sep 14, 2021 · 1 comment

Comments

@mikemhenry
Copy link
Contributor

Trace back here:

---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
/tmp/ipykernel_31131/1487240485.py in <module>
     12     )
     13 
---> 14     value_object_csv = models.FileValue.from_string(
     15                 "molWeight_data.csv", challenge=challenge
     16     )

/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/core/models.py in from_string(cls, filepath, challenge, evaluation)
    555         with open(filepath, "rb") as fp:
    556             instance.value.save(filename, File(fp))
--> 557         filecache.preserve_local_copy(instance.value, filepath)
    558         return instance

/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/core/filecache.py in preserve_local_copy(field_file, filepath)
     43     at filepath into the local cache path.
     44     """
---> 45     local_path = _local_cache_path(field_file)
     46     if not os.path.exists(local_path):
     47         logger.debug("Copying local file %s into %s", filepath, local_path)

/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/core/filecache.py in _local_cache_path(field_file)
     16 def _local_cache_path(field_file):
     17     local_path = os.path.join(settings.MEDIA_ROOT, field_file.name)
---> 18     os.makedirs(os.path.dirname(local_path), exist_ok=True)
     19     return local_path
     20 

/usr/lib64/python3.8/os.py in makedirs(name, mode, exist_ok)
    211     if head and tail and not path.exists(head):
    212         try:
--> 213             makedirs(head, exist_ok=exist_ok)
    214         except FileExistsError:
    215             # Defeats race condition when another thread created the path

/usr/lib64/python3.8/os.py in makedirs(name, mode, exist_ok)
    211     if head and tail and not path.exists(head):
    212         try:
--> 213             makedirs(head, exist_ok=exist_ok)
    214         except FileExistsError:
    215             # Defeats race condition when another thread created the path

/usr/lib64/python3.8/os.py in makedirs(name, mode, exist_ok)
    211     if head and tail and not path.exists(head):
    212         try:
--> 213             makedirs(head, exist_ok=exist_ok)
    214         except FileExistsError:
    215             # Defeats race condition when another thread created the path

/usr/lib64/python3.8/os.py in makedirs(name, mode, exist_ok)
    221             return
    222     try:
--> 223         mkdir(name, mode)
    224     except OSError:
    225         # Cannot rely on checking for EEXIST, since the operating system

PermissionError: [Errno 13] Permission denied: '/var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/media'

tl;dr need to

  1. Decide if we need the media file to be persistent
  2. Make sure we have the permissions correct ie
sudo mkdir /var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/media
sudo chmod g+s /var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/media
sudo chown webapp:webapp /var/app/venv/staging-LQM1lest/lib/python3.8/site-packages/media
@mikemhenry
Copy link
Contributor Author

@robbason this is just an issue for local "scratch" right? anything important ends up on S3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant