HybriD3-database / MatD3

Curatable database for experimental and theoretical data on solid materials.
https://hybrid3-database.readthedocs.io/en/latest/
BSD 2-Clause "Simplified" License
12 stars 4 forks source link

incident while testing selenium during setup #38

Closed kellyyma closed 1 year ago

kellyyma commented 1 year ago

I was trying to install MatD3 from scratch on my macbook using homebrew and eventually conda.

I had to install firefox (needs to be mentioned in instructions). More importantly, I also installed selenium as required. When running ./manage.py test I got the following error message: AttributeError: 'WebDriver' object has no attribute 'find_element_by_link_text' This leads to the following explanation online: https://stackoverflow.com/questions/72754331/webdriver-object-has-no-attribute-find-element-by-link-text-selenium-scrip which tells us that a particular line of code is no longer supported by selenium 4.3.0 and higher. We need to figure out if we need to upgrade the rest of the code base to request only selenium 4.3.0 and higher and what are the ramifications.

volkerblum commented 1 year ago

NB - Kelly and I are going through this together and the note is here because me need to make another strategic decision, which is whether to stick with the sometimes tricky pip based installation or to install via conda - @rayanc72 knows more, I think. The issue appears to be that Conda will, by default, install selenium > 4.3.0 at this time, whereas our requirements.txt specify selenium==3.141.0 . This only affects our testing, not the actual servers once they're in production. Nevertheless, the question is do we upgrade to > 4.3.0 and change our file tests.py to reflect the new selenium syntax.

I am for updating (always better) but we also need a documented process for a conda based install.

Those are the action items from this issue (sorry that we don't use the issue tracker more for logs like this one).

rayanc72 commented 1 year ago

Hi @volkerblum,

Here's the complete installation guide while using the conda environment on a mac. We'll need to update the tests.py file at some point to work with this.

Installation Guide of MatD3 Using Conda Environment

Prerequisites

Before you proceed with the installation, ensure you have the following software installed on your system:

  1. Anaconda or Miniconda
  2. Git (to clone the repository)
  3. MySQL (If you intend to use MySQL instead of SQLite)*

[* In older macs (using intel chips), MySQL installation needs to be carried out with the legacy password option.]

Step 1: Clone the MatD3 repository

To get started, clone the MatD3 repository from GitHub:

git clone https://github.com/HybriD3-database/MatD3.git

Step 2: Create a New Conda Environment

Navigate to the MatD3 directory that was created after cloning the repository:

cd MatD3

create a new Conda environment for MatD3 using the following command:

conda create -n matd3_local pip

Step 3: Activate the Conda Environment

Activate the newly created environment using the following command:

conda activate matd3_local

Step 4: Install the Required Packages

  1. Edit the 'requirements.txt' file to remove the version requirements and mysqlclient:
Django
matplotlib
numpy
Pillow
python-dateutil
sentry-sdk
raven
python-decouple
django-nested-admin
djangorestframework
coverage
selenium
requests
Sphinx
gunicorn
sphinx_rtd_theme
django-filter>=2.4.0
  1. to install these, use the following command:
pip install -r requirements.txt
  1. Uncomment the following line in mainproject/settings.py:
DEFAULT_AUTO_FIELD='django.db.models.AutoField' 
  1. Install geckodriver from conda conda install -c conda-forge geckodriver

Step 5: Create a .env file and Perform Additional Set-Ups, if Using MySQL

Copy the provided env.example file:

cp env.example .env

Additionally, if you wish to use MySQL:

  1. Install MySQL client for conda

    conda install -c conda-forge mysqlclient
  2. in the .env file, specify that you are using MySQL: set USE_SQLITE=False (the Default is True)

  3. Create a database for using with MySQL:

mysql -u <your_mysql_username> -p 

This should prompt you to provide your MySQL password. After entering that, use,

create database <your_database_name>;
exit;
  1. Update the MySQL database name, and your MySQL user info in the mainproject/settings.py file:
# Database
...
else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': '<your_database_name>',
            'USER': config('DB_USER', default='<your_mysql_username>'),
            'PASSWORD': config('DB_PASSWORD', default='<your_mysql_password>'),
            'HOST': 'localhost',
            'PORT': '',
        }
    }

Step 6: Initialize the Database

To Initialize static files and perform database migrations, run the following command:

./manage.py collectstatic
./manage.py migrate

Step 7: Create a Superuser

Run the following command:

./manage.py createsuperuser

Step 8: Start the Server

Run the following command:

./manage.py runserver
rayanc72 commented 1 year ago

I'm closing this issue and opening a new one for updating the test.py to work with the updated Python modules.