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

285 enhancement csv upload admin portal #287

Closed

Conversation

roald-teunissen
Copy link
Contributor

Hi @mrchrisadams, as you can see in the files, I've been working on reading a csv file and validating it.
For now I'm stuck on something really simple and I don't know what I'm doing wrong.

It can't find the function validate_csv_file, even though I have declared it.

@roald-teunissen roald-teunissen self-assigned this Aug 24, 2022
@roald-teunissen roald-teunissen linked an issue Aug 24, 2022 that may be closed by this pull request
@gitpod-io
Copy link

gitpod-io bot commented Aug 24, 2022

@roald-teunissen
Copy link
Contributor Author

Hi @mrchrisadams, as you can see in the files, I've been working on reading a csv file and validating it. For now I'm stuck on something really simple and I don't know what I'm doing wrong.

It can't find the function validate_csv_file, even though I have declared it.

Fixed it 👍

@roald-teunissen
Copy link
Contributor Author

roald-teunissen commented Aug 25, 2022

  • Automatically install Pandas with the pre-build
  • Find a way to convert ip ranges (start and ending ip) to a ip network (lib doesn't provide a function for it)

apps/greencheck/importers/importer_csv.py Show resolved Hide resolved
apps/greencheck/tests/test_importer_csv.py Show resolved Hide resolved
def sample_data_as_list(sample_data_raw):
"""
Retrieve a locally saved sample of the population to use for this test and parse it to a list
Return: List
Copy link
Member

Choose a reason for hiding this comment

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

if you're adding a function signature and being explicit about the return value, and you please use the python typing in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!
I will include this later on, when I am sure what data structures is best suited for this function

apps/greencheck/tests/test_importer_csv.py Show resolved Hide resolved
# # Start and ending ip range
# start_ip = data.iloc[:,0]
# end_ip = data.iloc[:,1]
# Create network from these
Copy link
Member

Choose a reason for hiding this comment

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

Is it necessary to create an IP Network? We store IPranges in the database, and while a network can resemble an IP range that has a start and end IP, they're not necessarily the same thing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

At the moment, the saving interface function works with IP networks.
The reasoning behind this was so that we could easily have a list with a simple dimensions.
This posed a problem before, so I can this fundamental part around by allowing ip ranges.

@mrchrisadams
Copy link
Member

@roald-teunissen can you share some of the error messages you see?

Use the backticks to share somethign like so:

apps/greencheck/tests/test_importer_csv.py:56: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

cls = <apps.greencheck.importers.importer_csv.CsvImporter object at 0x7f1c479bbc40>
data = <function sample_data_raw at 0x7f1c48552f70>

    def validate_csv_file(cls, data):
>       if len(data.columns) == 1 or len(data.columns) == 2:
E       AttributeError: 'function' object has no attribute 'columns'

apps/greencheck/importers/importer_csv.py:50: AttributeError

@roald-teunissen
Copy link
Contributor Author

I keep getting an access denied message for the new page I made.
I'm not sure what step I am missing here, I went over almost the same steps as the other pages went through.

Message
Traceback

@roald-teunissen
Copy link
Contributor Author

Hi @mrchrisadams, as promised I've uploaded my work so you can pick it up from here.
I've also added some pretty handy make commands.

Before you start with this, it is important to understand that the link to the uploading page can normally be shown to admin users. If you use the make commands I've created, you will not have direct access as an admin. This is why I have temporarily placed the button in the list that will always be shown. Please make sure to put this "start_csv_import_button" back into the admin_editable listing.

@mrchrisadams
Copy link
Member

Thanks @roald-teunissen - and thanks the heads up on the admin_editable bits 👍

@mrchrisadams
Copy link
Member

Closing this in favour of #296

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.

[ENHANCEMENT] CSV upload of ip ranges in the admin portal
2 participants