Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
workspaces
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
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ssa
workspaces
Commits
bc33dbb5
Commit
bc33dbb5
authored
1 year ago
by
Charlotte Hausman
Browse files
Options
Downloads
Patches
Plain Diff
fix PPR condor correction to keep correct format and encoding
parent
48a90c5a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!1571
catch 2.8.2.3 up with main
,
!1550
Fix PPR condor correction to keep correct format and encoding
Pipeline
#13292
passed
1 year ago
Stage: pull-db
Stage: build-packages
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/cli/executables/pexable/casa_envoy/casa_envoy/auditor.py
+58
-7
58 additions, 7 deletions
.../cli/executables/pexable/casa_envoy/casa_envoy/auditor.py
apps/cli/executables/pexable/casa_envoy/test/input_files/PPR.xml
+1
-1
1 addition, 1 deletion
...i/executables/pexable/casa_envoy/test/input_files/PPR.xml
with
59 additions
and
8 deletions
apps/cli/executables/pexable/casa_envoy/casa_envoy/auditor.py
+
58
−
7
View file @
bc33dbb5
...
...
@@ -25,13 +25,34 @@ import shutil
from
pathlib
import
Path
from
typing
import
Dict
,
List
,
Union
import
prettierfier
import
lxml.etree
from
bs4
import
BeautifulSoup
from
lxml
import
etree
from
casa_envoy.enums
import
ProductType
from
casa_envoy.interfaces
import
AuditorIF
from
casa_envoy.schema
import
AbstractTextFile
PPR_HEADER
=
"""
<?xml version=
"
1.0
"
encoding=
"
UTF-8
"
standalone=
"
yes
"
?>
"""
PPR_FORMATTER
=
"""
<xsl:stylesheet version=
"
1.0
"
xmlns:xsl=
"
http://www.w3.org/1999/XSL/Transform
"
>
<xsl:output indent=
"
yes
"
/>
<xsl:strip-space elements=
"
*
"
/>
<!-- IDENTITY TRANSFORM -->
<xsl:template match=
"
@*|node()
"
>
<xsl:copy>
<xsl:apply-templates select=
"
@*|node()
"
/>
</xsl:copy>
</xsl:template>
<!-- RUN normalize-space() ON ALL TEXT NODES -->
<xsl:template match=
"
text()
"
>
<xsl:copy-of select=
"
normalize-space()
"
/>
</xsl:template>
</xsl:stylesheet>
"""
def
get_fields_for
(
product_type
:
str
,
filename
:
str
)
->
list
:
cal_metadata_list
=
[
...
...
@@ -128,6 +149,12 @@ class AuditFiles(AuditorIF):
return
True
def
correct_for_condor
(
self
,
ppr
:
AbstractTextFile
)
->
AbstractTextFile
:
"""
Correct PPR.xml for HTCondor directory and path
:param ppr: content of the waiting PPR
:return: updated content of PPR written to working area
"""
shutil
.
copy
(
ppr
.
filename
,
"
./working
"
)
os
.
chdir
(
"
./working
"
)
...
...
@@ -135,8 +162,22 @@ class AuditFiles(AuditorIF):
parsed_xml
.
find
(
"
RootDirectory
"
).
string
=
self
.
settings
[
"
rootDirectory
"
]
parsed_xml
.
find
(
"
RelativePath
"
).
string
=
self
.
settings
[
"
processingDirectory
"
]
strip_declaration
=
str
(
parsed_xml
).
split
(
"
\n
"
)[
1
:]
fixed_declaration
=
""
.
join
(
strip_declaration
)
corrected_xml
=
etree
.
fromstring
(
fixed_declaration
)
formatter
=
etree
.
XSLT
(
etree
.
fromstring
(
PPR_FORMATTER
))
corrected_content
=
lxml
.
etree
.
tostring
(
formatter
(
corrected_xml
),
pretty_print
=
True
,
xml_declaration
=
True
,
encoding
=
"
UTF-8
"
,
standalone
=
True
,
)
with
open
(
ppr
.
filename
,
"
w
"
)
as
file
:
file
.
write
(
prettierfier
.
prettify_xml
(
parsed_xml
.
prettify
(),
indent
=
4
))
file
.
write
(
corrected_content
.
decode
(
))
os
.
chdir
(
"
../
"
)
return
ppr
...
...
@@ -150,7 +191,9 @@ class AuditFiles(AuditorIF):
self
.
logger
.
info
(
"
Correcting PPR.xml for condor processing...
"
)
file
=
self
.
correct_for_condor
(
file
)
valid
=
self
.
check_required_fields
(
file
=
file
,
fields
=
get_fields_for
(
self
.
product_type
,
file
.
filename
))
valid
=
self
.
check_required_fields
(
file
=
file
,
fields
=
get_fields_for
(
self
.
product_type
,
file
.
filename
)
)
if
not
valid
:
invalid_files
.
append
(
file
.
filename
)
...
...
@@ -173,7 +216,9 @@ class AuditDirectories(AuditorIF):
current
=
os
.
getcwd
()
needed
=
self
.
rootDirectory
+
"
/
"
+
self
.
relative_path
if
needed
!=
current
:
self
.
logger
.
error
(
"
DIRECTORY ERROR: not in correct directory for processing.
"
)
self
.
logger
.
error
(
"
DIRECTORY ERROR: not in correct directory for processing.
"
)
return
False
else
:
working
=
Path
(
current
+
"
/working
"
).
is_dir
()
...
...
@@ -190,9 +235,13 @@ class AuditDirectories(AuditorIF):
self
.
logger
.
info
(
"
Checking products/ for calibration tables...
"
)
cal_data
=
os
.
listdir
(
Path
(
current
+
"
/products/
"
))
if
len
(
cal_data
)
>
0
:
self
.
logger
.
info
(
"
Calibration data is available. Proceeding...
"
)
self
.
logger
.
info
(
"
Calibration data is available. Proceeding...
"
)
else
:
self
.
logger
.
error
(
"
FAILURE: calibration data not found in products/
"
)
self
.
logger
.
error
(
"
FAILURE: calibration data not found in products/
"
)
return
False
# if (
# self.parameters["product_type"] == ProductType.VLASS_IMG.value
...
...
@@ -217,4 +266,6 @@ class AuditDirectories(AuditorIF):
self
.
logger
.
error
(
"
FAILURE: data not found in rawdata/
"
)
return
False
else
:
self
.
logger
.
error
(
"
DIRECTORY ERROR: A directory is missing from the processing root directory.
"
)
self
.
logger
.
error
(
"
DIRECTORY ERROR: A directory is missing from the processing root directory.
"
)
This diff is collapsed.
Click to expand it.
apps/cli/executables/pexable/casa_envoy/test/input_files/PPR.xml
+
1
−
1
View file @
bc33dbb5
<?xml version=
"
1.0
"
?>
<?xml version=
'
1.0
' encoding='UTF-8' standalone='yes'
?>
<ns2:SciPipeRequest
xmlns:ns2=
"Common/pipelinescience/SciPipeRequest"
>
<ProjectSummary>
<ProposalCode>
VLA/null
</ProposalCode>
...
...
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