-
Notifications
You must be signed in to change notification settings - Fork 11
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/#392_Unpack_gz_files_and_#391follow_redirects #405
Conversation
Update docs to be in line with working code
…pective logic to http-extractor-executor. Added jv test file for redirects and added file to automated tests.
… feature/392-Unpack-gz-files
…p-extractor on redirects
Feature/392 unpack gz files
@f3l1x98 can you provide guidance on how the failing example file can be turned into a unit test? |
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 you did not tag me in this to review but it popped up in my email. I left some spontaneous commments. For future work, it would be good to have only one PR per issue please.
example/thermoelectricMaterials.jv
Outdated
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 don't think we need new examples in the Jayvee repository right now, it would be better to move this to the SWC repo.
Also please don't provide examples that do not work. These files are meant as documentation for users of Jayvee, not to test implementation ;).
example/materials.jv
Outdated
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 don't think we need new examples in the Jayvee repository right now, it would be better to move this to the SWC repo.
return R.err({ | ||
message: `Archive is not a zip-archive`, | ||
diagnostic: { node: context.getCurrentNode(), property: 'name' }, | ||
}); | ||
} | ||
|
||
private async loadGzFileToInMemoryFileSystem( |
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.
This function should duplicate a lot of the loadZipFileToInMemoryFileSystem
logic. I assume only the extraction of files would be different, putting them into our in memory filesystem etc is all repeated logic.
It would be better to implement it that way, e.g., by extracting the shared logic of putting files into our in-memory file system into one function and reduce these two functions to just extracting the relevant archives and then using the new function to put files into a file system.
archivedObject, | ||
); | ||
|
||
const addedFile = fs.putFile( |
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 am very confused how this works because I can only see one putFile
call and no loops or iterations. Does this actually correctly expand gz archives with multiple files in them?
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.
To my understanding gzip is used to compress individual files. To compress multiple files with gzip, they have to be concated first, e.g to a .tar file. This I would implement in a different feature. Happy to further look into this, if you disagree.
@@ -19,7 +19,7 @@ export class ArchiveInterpreterMetaInformation extends BlockMetaInformation { | |||
archiveType: { | |||
type: PrimitiveValuetypes.Text, | |||
docs: { | |||
description: 'The archive type to be interpreted, e.g., `"zip"`.', | |||
description: 'The archive type to be interpreted, e.g., `"zip" or "gz`.', |
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.
description: 'The archive type to be interpreted, e.g., `"zip" or "gz`.', | |
description: 'The archive type to be interpreted, e.g., `"zip" or "gz".', |
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.
Changed to 'The archive type to be interpreted, e.g., "zip" or "gz".',
type: PrimitiveValuetypes.Boolean, | ||
defaultValue: true, | ||
docs: { | ||
description: 'Indicates, whether to follow redirects on get requests. If `false`, Redirects are disabled. Default `true`', |
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.
Redirects are not disabled, just not followed ;).
description: 'Indicates, whether to follow redirects on get requests. If `false`, Redirects are disabled. Default `true`', | |
description: 'Indicates, whether to follow redirects on get requests. If `false`, redirects are not followed. Default `true`', |
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.
Changed as suggested
@@ -126,6 +126,17 @@ export class HttpExtractorExecutor extends AbstractBlockExecutor< | |||
); | |||
} | |||
|
|||
if (responseCode === 302) { |
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.
301 is also a redirect code I assume.
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.
Changed to >= 301, as 300 is used for 'multiple choices'. The remaining 300 < response codes < 400
point to redirect location or are not used in get context.
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.
Please do not change it to >= 301, that makes it dependent on other code to ensure this does not handle 400+. You can change it to >=301 and <400 though.
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.
ok, done
Linting is failing for this PR btw, you can run the linter locally with |
If help is needed/wanted, yes. |
@A-M-A-X (in case you want me to review this again, you'll need to re-request the review on the top right, little icon next to my name). |
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.
Small changes to the function still but otherwise looks good 👍
} | ||
} | ||
|
||
private createBinaryAndPutFile( |
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 think there are two problems with this:
- Methods that have an "and" in their name are almost always to large and can be split up in an obvious way ;). In this case, I'd split this into
createBinary
andputFile
theoretically. - Changing objects that are parameters to a function as a sideeffect is often confusing and leads to errors. Here I would not change the inmemoryfilesystem as sideeffect of the function.
Combined, I'd rename the method to createFileFromArchive
(or similar) and just have line 120 to 128 in it, return the new BinaryFile
. Then habe the fs.putfile and assert outside of the function on it's own, I don't think they need their own function.
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.
- Moved
fs.putFile
and assertion outside of function. - Renamed function to
createFileFromArchive
and have it return the newBinaryFile
. - Removed now unused parameters.
…ive. Moved putFile logic outside
Wait |
Ah, nvm I am blind. It's fine, you can merge this into dev. |
@rhazn I think I am missing write acess to do the merge myself, or am I blind as well? |
Ah yeah might be on me. It's fine, I can merge these finally. |
[FEATURE] HTTPExtractor should follow redirects #391
Archive-Interpreter
thermoelectricMaterials.jv
File-Picker
receives a file - error on csv interpreter, as underlying file is in json formatCloses [FEATURE] Unpack gz files #392
[FEATURE] Unpack gz files #392
HTTP-Extractor
max redirects = 21
)followRedirects
attribute in HTTP-Extractor defaults totrue
materials.jv
Closes [FEATURE] HTTPExtractor should follow redirects #391