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

environment variables don't work from the python API #266

Open
delgadom opened this issue Apr 24, 2017 · 0 comments
Open

environment variables don't work from the python API #266

delgadom opened this issue Apr 24, 2017 · 0 comments
Labels
Milestone

Comments

@delgadom
Copy link
Member

  • DataFS version: 0.7.0
  • Python version: Python 3.4.5 :: Anaconda 4.2.0 (64-bit)
  • Operating System: Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-85-generic x86_64)

Description

We can get inconsistent behavior if we are using the command line vs the python api. Specifically, environment variables (e.g. DATAFS_DEFAULT_PROFILE, DATAFS_CONFIG_FILE, and DATAFS_REQUIREMENTS_FILE) have no affect on the python api, whereas they do in the cli.

Example

I've set up a profile called test, in which I have a bunch of repos. The following is a valid search in the test profile, but not in my default profile (impactlab):

In the CLI:

$ datafs search project5 variable3 scenario1.nc team1 task3 # no response

$ datafs --profile test search project5 variable3 scenario1.nc team1 task3
team1_project5_task3_variable3_scenario1.nc

$ export DATAFS_DEFAULT_PROFILE=test

$ datafs search project5 variable3 scenario1.nc team1 task3 # use new default
team1_project5_task3_variable3_scenario1.nc

In the python API:

Using the same session (with the environment variable set to 'test'), we don't have the correct default profile:

>>> import os, datafs
>>> print(os.environ['DATAFS_DEFAULT_PROFILE']
'test'
>>> api = datafs.get_api() # get default api (should be test)
>>> list(api.search(
...     'project5', 'variable3', 'scenario1.nc', 'team1', 'task3')) # conduct same search
[]
>>> api2 = datafs.get_api('test') # force use of 'test'
>>> list(api2.search(
...     'project5', 'variable3', 'scenario1.nc', 'team1', 'task3')) # conduct same search
[u'team1_project5_task3_variable3_scenario1.nc']
@delgadom delgadom added the bug label Apr 24, 2017
@delgadom delgadom added this to the 1.0 milestone Apr 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant