Skip to content

Conversation

@smangarole
Copy link
Contributor

@smangarole smangarole commented Aug 28, 2017

Please Note:

  1. Before submitting the PR, please review How to Contribute to Dynamo
  2. Dynamo Team will meet 1x a month to review PRs found on Github (Issues will be handled separately)
  3. PRs will be reviewed from oldest to newest
  4. If a reviewed PR requires changes by the owner, the owner of the PR has 30 days to respond. If the PR has seen no activity by the next session, it will be either closed by the team or depending on its utility will be taken over by someone on the team
  5. PRs should use either Dynamo's default PR template or one of these other template options in order to be considered for review.
  6. PRs that do not have one of the Dynamo PR templates completely filled out with all declarations satisfied will not be reviewed by the Dynamo team.
  7. PRs made to the DynamoRevit repo will need to be cherry-picked into all the DynamoRevit Release branches that Dynamo supports. Contributors will be responsible for cherry-picking their reviewed commits to the other branches after a LGTM label is added to the PR.

Purpose

The purpose of this PR is to Upload newly generated JSON files to S3. In this PR, I updated the TestFixtureSetup() to delete the files in the temp folder. This will enable us to upload a new set of files to s3 after every test run. This PR is a part of the testing tool that we are building

Declarations

Check these if you believe they are true

Reviewers

@mjkkirschner @ramramps @QilongTang

var jsonFolder = Path.Combine(tempPath, "json");
var jsonNonGuidFolder = Path.Combine(tempPath, "jsonNonGuid");

var jsonNonGuidFiles = Directory.GetFiles(jsonNonGuidFolder, "*.*", SearchOption.AllDirectories);
Copy link
Member

Choose a reason for hiding this comment

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

you need to either verify these paths exist or put these calls inside a try catch, Directory.GetFiles will throw if the directories don't exist... which they may not on a clean machine.

{
foreach (var file in files)
{
File.Delete(file);
Copy link
Member

Choose a reason for hiding this comment

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

this should probably be made more tolerant, assert that the files actually exist before you try this and check if the deletion succeeds, you may not have permissions when this call is made.

modelsGuidToIdMap.Clear();
DoWorkspaceOpenAndCompare(filePath, "json_nonGuidIds", ConvertCurrentWorkspaceToNonGuidJsonAndSave, CompareWorkspacesDifferentGuids, SaveWorkspaceComparisonDataWithNonGuidIds);

//UploadToS3() from Ram;
Copy link
Member

Choose a reason for hiding this comment

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

you will want to upload both the guid and non guid tests and all data files associated with those graphs so this should be called from the other serializationTest method as well.

Copy link
Member

Choose a reason for hiding this comment

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

hmm, you may want to add a breakpoint here and check if this method is called repeatedly... I dont think you want to make 2000 separate upload calls to s3, I think you just want to upload the two folders once.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If Dynamo is going to upload to S3, then the configurations should be moved to the config files or environment variables. Uploading to S3 is "sync" ing a folder on the machine with S3 storage location. So, one sync will get all the files in S3.

Copy link
Member

Choose a reason for hiding this comment

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

@ramramps @smangarole thats a good point... I dont think running these tests should upload to s3 - then what happens when a dev runs the test locally? It should not upload to s3. this should be some post test step or at least set with a flag or something.

Copy link
Contributor

@QilongTang QilongTang Aug 29, 2017

Choose a reason for hiding this comment

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

Please make uploading part seperate of Dynamo code. For internal tool, we probably can argue about it. But this will be wrapped in DynamoTest nuget package and spread publicly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

another thought here is upload should be from the script (job) after a successful build.

Siddhartha Mangarole added 3 commits August 30, 2017 10:00

try
{
jsonFilesList = Directory.GetFiles(jsonNonGuidFolder, "*.*", SearchOption.AllDirectories).ToList();
Copy link
Contributor

Choose a reason for hiding this comment

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

if jsonFolder exists but jsonNonGuidFolder does not, this will prevent deletion of the jsonFolder files. These should probably be in separate try/catch blocks.
Can you use Directory.Delete(jsonNonGuidFolder, true) here instead of deleting the files individually?

Copy link
Member

Choose a reason for hiding this comment

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

agree with @gregmarr 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

The current "delete files individually" method has the problem that as soon as you try to delete a file for which you don't have delete permission (or it's currently locked), then it aborts the entire operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added individual try...catch for each folder.

foreach (var file in files)
{
//Delete files if they exist
if (File.Exists(file))
Copy link
Contributor

Choose a reason for hiding this comment

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

This check isn't necessary (and the entire function may not be necessary if Directory.Delete works). If the file didn't exist, it wouldn't be in the list. If it did exist when the list was generated, but doesn't now, then it's still safe to call File.Delete on it, as deleting a non-existent file doesn't throw an exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. If I am using Directory.Delete, I can remove this method entirely.

{
modelsGuidToIdMap.Clear();
DoWorkspaceOpenAndCompare(filePath, "json_nonGuidIds", ConvertCurrentWorkspaceToNonGuidJsonAndSave, CompareWorkspacesDifferentGuids, SaveWorkspaceComparisonDataWithNonGuidIds);
DoWorkspaceOpenAndCompare(filePath, "json_nonGuidIds", ConvertCurrentWorkspaceToNonGuidJsonAndSave, CompareWorkspacesDifferentGuids, SaveWorkspaceComparisonDataWithNonGuidIds);
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like a trailing whitespace only change

var jsonNonGuidFolder = Path.Combine(tempPath, "jsonNonGuid");

var jsonFilesList = new List<string>();
var jsonNonGuidFilesList = new List<string>();
Copy link
Contributor

Choose a reason for hiding this comment

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

These two variables are now obsolete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, yes. Deleted!

@smangarole smangarole changed the title WIP: QNTM-1476: Upload JSON files to S3 QNTM-1476: Upload JSON files to S3 Sep 6, 2017
@smangarole smangarole merged commit fe43e7a into master Sep 6, 2017
@QilongTang QilongTang deleted the QNTM-1476 branch September 25, 2017 13:40
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.

6 participants