Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Freva Ingest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
freva
Freva Ingest
Commits
7b6bd6f6
Commit
7b6bd6f6
authored
3 years ago
by
Brian Lewis
Browse files
Options
Downloads
Patches
Plain Diff
Fix some dangling todos
parent
d35923c8
No related branches found
Branches containing commit
Tags
0.5.0
Tags containing commit
2 merge requests
!2
Ingest different DRS formats
,
!1
Ingest
Pipeline
#16269
passed
3 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
freva/src/drs/ingest.rs
+12
-6
12 additions, 6 deletions
freva/src/drs/ingest.rs
freva/src/drs/metadata.rs
+8
-3
8 additions, 3 deletions
freva/src/drs/metadata.rs
with
20 additions
and
9 deletions
freva/src/drs/ingest.rs
+
12
−
6
View file @
7b6bd6f6
...
...
@@ -145,12 +145,18 @@ async fn ingest_structure(
};
if
entry
.path
()
.is_file
()
{
// TODO: this conversion should probably take place within drs
let
path
=
Utf8PathBuf
::
from_path_buf
(
entry
.path
()
.to_path_buf
())
.unwrap
();
// TODO: this should too
if
!
structure
.verify_path
(
&
path
)
{
continue
;
}
let
path
=
match
Utf8PathBuf
::
from_path_buf
(
entry
.path
()
.to_path_buf
())
{
Ok
(
p
)
=>
p
,
Err
(
e
)
=>
{
warn!
(
"{} not a valid drs file, has non UTF8 characters in path:
\n
{:?}"
,
entry
.path
()
.display
(),
e
);
skipped
+=
1
;
continue
;
}
};
let
f
=
match
structure
.file_from_path
(
&
path
)
{
Ok
(
f
)
=>
f
,
...
...
This diff is collapsed.
Click to expand it.
freva/src/drs/metadata.rs
+
8
−
3
View file @
7b6bd6f6
...
...
@@ -87,7 +87,7 @@ impl Structure {
/// This is not comprehensive in that there are still paths where this would return `true` but which are not valid
/// for this structure. For example, if a path has the same `root_dir` and the same _number_ of components in its
/// directory structure, it will pass this even if it doesn't have the right `filename` structure for this.
///
*
TODO
*
: fix this if possible.
/// TODO: fix this if possible.
pub
fn
verify_path
<
P
:
AsRef
<
Path
>>
(
&
self
,
path
:
P
)
->
bool
{
let
path
=
path
.as_ref
();
...
...
@@ -113,6 +113,13 @@ impl Structure {
/// Extracts [`Metadata`] for a file path of this structure
pub
fn
file_from_path
(
&
self
,
path
:
&
Utf8PathBuf
)
->
Result
<
Metadata
,
Error
>
{
if
!
self
.verify_path
(
&
path
)
{
return
Err
(
Error
::
InvalidPath
{
path
:
path
.into
(),
reason
:
"file path does not match expected structure"
.to_owned
(),
});
}
let
parts
=
path
.strip_prefix
(
self
.root
())
.unwrap
()
// this is already done with `structure_from_path` so should be safe
...
...
@@ -268,8 +275,6 @@ impl TryFrom<&String> for Config {
/// Paths must be UTF-8.
#[derive(Debug,
PartialEq)]
pub
struct
Metadata
<
'a
>
{
// File doesn't feel quite right as a name since it isn't an open file but more of a path?
// in original, this is the string key rather than the actual structure but I think this can work here
structure
:
&
'a
Structure
,
/// map of { part name => value } e.g. "institute" => "cpc"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment