-
Notifications
You must be signed in to change notification settings - Fork 20
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
Feature/#32 dotenv #38
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to change the error txt in def command_line_run():
if defaults['facebook_token'] is None and defaults['XAuthToken'] is None:
raise('ERROR: No facebook token nor XAuth token in config.txt. '
'You must supply a facebook token in order to use tindetheus!')
Is there a Windows equivalent to a .env? Windows users can either set the environment variables the usual way, or create a local batch script to set them (which they run prior to executing tindetheus). You could do A/B testing with the same model using a.bat and b.bat! The env.bat file could look like @ECHO OFF
rem Tindetheus
set TINDETHEUS_MODEL_DIR=20170512-110547
set TIDETHEUS_IMAGE_BATCH=1000
set TINDETHEUS_DISTANCE=5
set TINDETHEUS_LIKES=100
set TINDETHEUS_RETRIES=20
rem Tinder
set TINDER_AUTH_TOKEN=TODO
rem Facebook
set FACEBOOK_AUTH_TOKEN=TODO This is a great change! and it gets rid of some of the worst code. |
This is interesting. The above sounds like a suitable solution. It's probably the best for most users because they can set it globally then don't need to worry about it when running the program. Another solutions could be to use the https://pypi.org/project/python-dotenv/ library. I planned on using it when creating some example notebooks for #31 and it should work on all OSs. It works by reading the same .env as the Makefile. |
2a7e58e
to
0f38cc4
Compare
23add56
to
342f34e
Compare
Please test the new Windows compatibility. Running the project like normal (without the Makefilie) should automatically pick up the Regards #38 (comment), I've updated the documentation. Please have a look and let me know if there's anything I'm missed. I imagine the version and changelog changes should be make on a separate branch as it is not related to the dotenv feature? |
*EDITED March 25 2020 19:46 pacific time: Nevermind, the .env didn't work when I moved the from tindetheus import config. Do you know why the script (tindetheus.exe) is only picking up the .env from the installation folder and not the local folder? I imagine making a function to run config.py could help resolve this issue, but I'm not sure. Will play around more when I get free time. I removed my suggestion about placing
'''
Settings are stored in your config.txt file. A typically config.txt will
contain the following:
facebook_token = XXXXXXX # your facebook token hash
model_dir = 20170512-110547 # the location of your model directory
image_batch = 1000 # number of images to load in a batch during train
# the larger the image_batch size, the faster the training process, at the
# cost of additional memory. A 4GB machine may struggle with 1000 images.
distance = 5 # Set the starting distance in miles
likes = 100 # set the number of likes you want to use
# note that free Tinder users only get 100 likes in 24 hours
\n
Optional arguments will overide config.txt settings.
''' could be '''
You can now store all default optional parameters in your environment variables! This means you can set your starting distance, number of likes, and image_batch size without manually specifying the options each time. This is an example .env file:
FACEBOOK_AUTH_TOKEN="TODO" # your facebook token hash
# alternatively you can use the XAuthToken
# TINDER_AUTH_TOKEN="TODO"
TINDETHEUS_MODEL_DIR="/models/20170512-110547" # the location of your facenet model directory
# see https://github.com/davidsandberg/facenet#pre-trained-models for other
# pretrained facenet models
TINDETHEUS_IMAGE_BATCH=1000 # number of images to load in a batch during train
# the larger the image_batch size, the faster the training process, at the
# cost of additional memory. A 4GB machine may struggle with 1000 images.
TINDETHEUS_DISTANCE=5 # Set the starting distance in miles
TINDETHEUS_LIKES=100 # set the number of likes you want to use
# note that free Tinder users only get 100 likes in 24 hours
TINDETHEUS_RETRIES=20
'''
|
I should add that the .env works fine on windows when running bits from a jupyter notebook, ipython or python console, but it doesn't work when calling the run script tindetheus.exe. ie running python
>>> from tindetheus import config sets config properly on windows |
I think the version agnostic way to look for a .env file on windows will end up being import os
from dotenv import load_dotenv
cwd = os.getcwd()
load_dotenv(dotenv_path=os.path.join(cwd, '.env')) but let me test if that creates linux issues. |
from the discussion in #38 This change uses dotenv to search the current working directory for a .env file. Hopefully this is a good comprimise between linux and Windows compatibility. Also this changes adds the MIT license to the top of file
from the discussion in cjekel#38 This change uses dotenv to search the current working directory for a .env file. Hopefully this is a good comprimise between linux and Windows compatibility. Also this changes adds the MIT license to the top of file
from the discussion in cjekel#38 This change uses dotenv to search the current working directory for a .env file. Hopefully this is a good comprimise between linux and Windows compatibility. Also this changes adds the MIT license to the top of file
Depends on #35. Resolves #32
If merged, we can then use the environment variables when using the Docker image.