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

add key to get confirmed trip in read_data #798

Merged
merged 2 commits into from
Feb 20, 2021

Conversation

corinne-hcr
Copy link
Contributor

No description provided.

time_query=None, geo_query=None)
def read_data(uuid=None,key='cleaned_trip'):
trips = None
if key == 'confirmed_trip':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is functionally correct, but poor design. It would require modification every time we needed to switch to a new type of trip.

Please pass the key type in directly. The calling site will then need to pass in esda.CONFIRMED_TRIP_KEY or esda.CLEANED_TRIP_KEY.

Copy link
Contributor Author

@corinne-hcr corinne-hcr Feb 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But all existing files that run this pipeline doesn't pass in any key type. Naomi's files don't pass in keys and they use CLEANED_TRIP_KEY. I am afraid your suggested change would need to change many files...
Also, I don't see the difference after make such change. If you need to pass in esda.CONFIRMED_TRIP_KEY or esda.CLEANED_TRIP_KEY anyway, it would still choose one type of trip(the line of codetrips = esda.get_entries(esda.CONFIRMED_TRIP_KEY, uuid, time_query=None, geo_query=None) only choose one trip)
. And all existing files have to modified to pass in the key.
Can I not make this change? I think that's good to keep the existing files work and also flexible for future files.

If in the future, we need to get another type of trip, we indeed to modify this file, just add if statement and get_entries. But that doesn't hurt all existing files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you would have to change all the files even with your change, though. Your check is if 'confirmed_trip':... elif 'cleaned_trip'

If it is neither, what will your code do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then we will see what kind of trip other people need to get. It indeed needs to add other if statements and other entry keys but we don't need to modify other files.
Even if I change this file now, that one line of codetrips = esda.get_entries(esda.CONFIRMED_TRIP_KEY, uuid, time_query=None, geo_query=None) just read one kind of trips. Then I need to add all keys and maybe some of them wouldn't be used. I think we just make changes as needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't need to change all files. Before I made this change, Naomi just read in cleaned trips, so I set cleaned_trip to default, other existing files can run correctly without passing in key type. the evaluation I am doing (needs confirmed trip, different from the existing files) needs to pass inconfirmed_trip and the pipeline can choose confirmed trip key.

Copy link
Contributor

@shankari shankari Feb 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're right! I missed that detail.

But you can do that with esda.CLEANED_TRIP as well. Just set that to the default.
Fundamentally, I don't see what creating a new string and adding if checks gives you instead of just using esda.* directly.

Comment on lines 43 to 50
def read_data(uuid=None,key='cleaned_trip'):
trips = None
if key == 'confirmed_trip':
trips = esda.get_entries(esda.CONFIRMED_TRIP_KEY, uuid,
time_query=None, geo_query=None)
elif key == 'cleaned_trip':
trips = esda.get_entries(esda.CLEANED_TRIP_KEY, uuid,
time_query=None, geo_query=None)
Copy link
Contributor

@shankari shankari Feb 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def read_data(uuid=None,key='cleaned_trip'):
trips = None
if key == 'confirmed_trip':
trips = esda.get_entries(esda.CONFIRMED_TRIP_KEY, uuid,
time_query=None, geo_query=None)
elif key == 'cleaned_trip':
trips = esda.get_entries(esda.CLEANED_TRIP_KEY, uuid,
time_query=None, geo_query=None)
def read_data(uuid=None,key=esda.CLEANED_TRIP):
trips = esda.get_entries(key, uuid,
time_query=None, geo_query=None)

@shankari
Copy link
Contributor

shankari commented Feb 20, 2021

@corinne-hcr Can you please indicate the testing done before I merge?

@corinne-hcr
Copy link
Contributor Author

OK. All checks passed.
I can get confirm trips after making this change by calling
trips = pipeline.read_data(uuid=user, key=esda.CONFIRMED_TRIP_KEY)

@shankari
Copy link
Contributor

I don't think the checks actually cover this code path (which is a different fix). But good to know that it works in the notebook as well.

@shankari shankari merged commit f4ed2a7 into e-mission:master Feb 20, 2021
jf87 pushed a commit to jf87/e-mission-server that referenced this pull request Jun 21, 2021
* add key to get confirmed trip in read_data

* modify read_data function
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

Successfully merging this pull request may close these issues.

2 participants