-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
[16.0][MIG] edi_storage_oca: Migration to 16.0 #26
[16.0][MIG] edi_storage_oca: Migration to 16.0 #26
Conversation
QuocDuong1306
commented
Oct 10, 2023
- Migrate to v16
- Change the dependency from storage_backend to fs_storage
Ack files should be treated as incoming records. Receive files is not handled yet by the framework and will be added soon.
* A cron job check related storage on edi backends to create the needed exchange files. * Add basic receive component.
…all runtime fixes.
…filenames from storage. Also extend help in `exchange_filename_pattern` field to clarify usage.
@@ -39,7 +39,7 @@ def test_export_file_already_done(self): | |||
self.record.edi_exchange_state = "output_sent" | |||
mocked_paths = {self._file_fullpath("done"): self.fakepath} | |||
# TODO: test send only w/out cron (make sure check works) | |||
self._test_run_cron(mocked_paths) | |||
self._test_run_cron(mocked_paths, skip_sent=False) |
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.
why do we have to add this change?
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.
Because in tests
that have some case with the status output_sent
so we use the flag skip_sent
to ignore another case:
skip_sent
= True --> ignore records that were already sentskip_sent
= False ---> send it
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.
I know what it does 😉
I mean: why was not needed before and it is?
606e358
to
7c88d53
Compare
7c88d53
to
d2168b0
Compare
d2168b0
to
a2fc4e3
Compare
a2fc4e3
to
b0e99b8
Compare
bits.append(r"\." + exchange_type.exchange_file_ext) | ||
pattern = "".join(bits) | ||
# TODO: clean this up, .find_files is deprecated in fs_storage | ||
full_paths = self.storage_id.find_files(pattern, full_input_dir_pending) |
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.
Hi @QuocDuong1306 and @simahawk
I am testing this PR and the method find_files
(https://github.com/OCA/storage/blob/1a4d80faaab0ddf6dfc80d867472dd6ce4777c5f/fs_storage/models/fs_storage.py#L373) is not returning the full path from the root for me. Maybe you know what I may be missing.
I have an FTP where the home folder contains /import folder to import files. When the call to the method is done like self.fs.ls(relative_path, detail=False)
being relative_path "/import", I just get the filename of the file inside the folder.
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.
I'll have a look soon
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.
@JordiMForgeFlow are you using directory_path
? If yes, you might have inconsistent results. See OCA/storage#311
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.
@simahawk I am not using directory_path. Nevertheless, I have been testing and I have been able to get it working fine by assuming that find_files returns only the filename, not the full path.
The problem is mainly that, if for example I have a file test_file.xml in a folder called import, the find_files method returns test_file.xml. Then, when the line return [p[pending_path_len:].strip("/") for p in full_paths]
is executed, the filename stored in the exchange record is left as ile.xml (stripping the first characters as it assumes that it is actually the full path)
# otherwise is impossible to retrieve input files and acks | ||
# (the date will never match) | ||
# TODO: clean this up, .get is deprecated in fs_storage | ||
return self.storage.get(path.as_posix(), binary=binary) |
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.
@simahawk @QuocDuong1306 another issue that I am seeing is when sending a file. In the send component, a check is done before sending to make sure a file is not sent twice. The check ends up in this line, doing a storage.get.
I suppose it has to do with the new fs storage, but doing the get for a file that does not exist raises a different error than FileNotFoundError. The error is:
ValueError: <class 'ftplib.error_perm'>: "550 Can't open *****: No such file or directory"
(being ***** the filepath being accessed)
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.
I have created a PR at here: fsspec/filesystem_spec#1494
What is the stage of this PR? |
It works fine except for the issue I mentioned #26 (comment). I have been using a custom branch where I simply fixed what I commented and it has been working fine for some weeks already. |
@JordiMForgeFlow , Why not add this fix to this branch? Will @simahawk merge it anyway or do we need to get the coverage? I need this module actually for 17.0 so I am waiting. =) |
The fix I added is basically changing |
@john-herholz-dt @JordiMForgeFlow @QuocDuong1306 If it's fine for you all I'd merge what we have here as it is and then we iterate again for fixes (whoever has the chance to do it 1st 😉) |
Super fine! |
@simahawk LGTM! I will open a PR with the fix regarding the paths. |
/ocabot merge nobump |
Hey, thanks for contributing! Proceeding to merge this for you. |
Congratulations, your PR was merged at 7abe3a4. Thanks a lot for contributing to OCA. ❤️ |
@QuocDuong1306 why did you change storage_backend to fs_storage if there is no migration scripts there? If we migrate from 15 to 16, all the backends that are related to a storage will fail... Actually, storage_backend module already exists on 16 and this module should replace the original module. But no migration scrips have been created besides a comment on an issue. |
@nilshamerlinck @QuocDuong1306 could you please have a look and evaluate how to get a script to migrate? |