Re: The obligation of free stuff: Google Storage

2010-06-10 Thread Richard Hainsworth
Ideally [at least, what I would like], managing a file on a remote 
resource should be the same as managing one locally, eg.


my Amazon $fn = open("$path-to-input-file-location/$file-name", :r) or 
die $!;

for $fn.readlines { };
$fn.close;

my Google $fn = open("$path-to-output-file-location/$file-name", :w) or 
die $!;

for @lots-of-data -> $item { $fn.say: $item };
$fn.close;

If it is possible to make file on a cloud system as easy to manipulate 
as a local file, that will aid the acceptibility of perl6.


Hence, the use of 'open', 'close', 'say', 'readlines', rather than 
'connect', 'put', 'get'.


The issue - it seems to me - is that the connection between a computer 
and its local filesystem has such a low probability of failure (viz., 
disk failure or disk full) that is can normally be ignored, but there is 
relatively high probability of a connection failure between the computer 
and a remote site and so it would be normal to have exception handling 
in the code.


That means the designer of the API should indicate how these exceptions 
should be handled so that a program doesnt hang in a loop that is 
expecting data from a remote resource whose server has disconnected.




On 06/10/2010 03:24 AM, Aaron Sherman wrote:

On Wed, Jun 9, 2010 at 10:04 AM, Aaron Sherman  wrote:
   

Has anyone begun to consider what kind of filesystem interface we want
for things like sftp, Amazon S3, Google Storage and other remote
storage possibilities? Is there any extant work out there, or should I
just start spit-balling?
 

In the absence of anything forthcoming and a totally arbitrary sense
of urgency ;-) here's what I think I should do:

IO::FileSystems (S32) gives us some basics and the Path role also
provides some useful features.

I will start there and build an IO::FileSystems::VFS roughly like:

class IO::VFS is IO::FileSystems {
   ...
   # Session data if applicable
   has IO::VFS::Session $.session;

  # Many methods take a $context which, if supplied
  # will contain back-end specific data such as restart markers
  # or payment model information. I'll probably define
  # a role for the context parameter, but otherwise
  # leave it pretty loose as a back-end specific structure.

   # A simple operation that guarantees a round-trip to the filesystem
   method nop($context?) { ... }

   # list of sub-IO::VFS partitions/buckets/etc
   method targets($context?) { ... }
   method find_target($locator, $context?) { ... }

   # Means of acquiring file-level access through a VFS
   method find($locator, $enc = $.session.encoding, $context?) { ... }
   method glob(Str $matcher, $enc = $.session.encoding, $context?) { ... }

   # Like opening and writing to filehandle, but the operation is totally
   # opaque and might be a single call, senfile or anything else.
   # Note that this doesn't replace $obj.find($path).write(...)
   method put($locator, $data, $enc = $.session.encoding, $context?) { ... }

   # Atomic copy/rename, etc. are logically filesystem operations, even though
   # they might have counterparts at the file level. The distinction being that
   # at the filesystem level I never know nor care what the contents of the
   # file are, I just ask for an operation to be performed on a given path.
   method copy($from, $to, $enc = $.session.encoding, $context?) { ... }
   method rename($from, $to, $enc = $.session.encoding, $context?) { ... }
   method delete($locator, $enc = $.session.encoding, $context?) { ... }

   # service-level ACLs if any
   method acl($locator, $context?) { ... }
}

The general model I imagine would be something like:

   my IO::VFS::S3 $s3 .= new();
   $s3.session.connect($amazonlogininfo);
   my $bucket = $s3.find_target($bucket_name);
   $bucket.put("quote.txt", "Now is the time for all good men...\n");
   say "URI: ", $bucket.find("quote.txt").uri;

or

  my IO::VFS::GoogleStorage $goog .= new();
  $goog.session.connect($googlelogininfo);
  my $bucket = $goog.find_target($bucket_name);
  $bucket.put("quote.txt", "Now is the time for all good men...\n");
  say "URI: ", $bucket.find("quote.txt").uri;

or

  my IO::VFS::SFTP $sftp .= new();
  $sftp.session.connect(:host, :user, :password);
  my $filesystem = $sftp.find_target("/tmp");
  $filesystem.put("quote.txt", "Now is the time for all good men...\n");
  say "URI: ", $filesystem.find("quote.txt").uri; # using sftp:...

Notice that everything after $obj.session.connect is identical except
for my choice of variable names. In fact, you shouldn't have to worry
about what storage back-end you're using as long as you have a valid
VFS handle. Really path names are the only thing that might trip you
up.

Thoughts?

I think that in order to do this, I'll need the following support
libraries which may or may not exist (I'll be looking into these):

IO::FileSystems
Path
HTTP (requires socket IO, MIME, base64, etc.)
Various crypto libs

I don't intend to provide a finished implementation of any of these
where they don't already exi

Re: The obligation of free stuff: Google Storage

2010-06-10 Thread Leon Timmermans
On Thu, Jun 10, 2010 at 9:15 AM, Richard Hainsworth
 wrote:
> Ideally [at least, what I would like], managing a file on a remote resource
> should be the same as managing one locally, eg.
>
> my Amazon $fn = open("$path-to-input-file-location/$file-name", :r) or die
> $!;
> for $fn.readlines { };
> $fn.close;
>
> my Google $fn = open("$path-to-output-file-location/$file-name", :w) or die
> $!;
> for @lots-of-data -> $item { $fn.say: $item };
> $fn.close;
>

I agree it should be similar to normal FS interactoin to make matters
as intuitive as possible, but I horrified by the idea of overloading
open() that way. That's a PHP mistake I wouldn't like seeing repeated.
If you want open to do something that's not really opening a file, you
should be explicit about it.

Leon


Re: The obligation of free stuff: Google Storage

2010-06-10 Thread Mark J. Reed
On Thursday, June 10, 2010, Leon Timmermans  wrote:
> I agree it should be similar to normal FS interactoin to make matters
> as intuitive as possible, but I horrified by the idea of overloading
> open() that way

But open is already overloaded in p5, with pipes etc.  We don't want
to repeat the mistakes of the past, and the fact that open(FH, $foo)
could run an arbitrary shell command was arguably a mistake, but
transparent access to storage where possible  is the way to go.

We can provide a way to limit the behavior when you want - a pragma,
option to open(), or just sticking "file://" in front of a value to
force its interpretation as a plain pathname - but even then, who
knows what Fuse filesystem might be mounted and doing strange things
with your innocuous-looking file access?  I'd rather have that
flexibility directly supported in the language.

Of course, different types of storage have different features; there's
no completely unified interface.  But to the extent that a cloud disk
system or document database functions as a collection of data blobs
accessed by a pathlike key, enabling the standard filesystem access
pattern for it (in addition to whatever specific functionality it
needs) makes sense, IMHO.


.

-- 
Mark J. Reed 


Re: The obligation of free stuff: Google Storage

2010-06-10 Thread Brandon S. Allbery KF8NH

On Jun 10, 2010, at 07:22 , Leon Timmermans wrote:

I agree it should be similar to normal FS interactoin to make matters
as intuitive as possible, but I horrified by the idea of overloading
open() that way. That's a PHP mistake I wouldn't like seeing repeated.
If you want open to do something that's not really opening a file, you
should be explicit about it.



Out of curiosity and at a tangent:  do you feel the same about FUSE?   
Gnome-VFS?


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com
system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu
electrical and computer engineering, carnegie mellon universityKF8NH




PGP.sig
Description: This is a digitally signed message part


r31189 -[S06] print default usage messag to standard output, by petition from avar++

2010-06-10 Thread pugs-commits
Author: moritz
Date: 2010-06-11 08:11:20 +0200 (Fri, 11 Jun 2010)
New Revision: 31189

Modified:
   docs/Perl6/Spec/S06-routines.pod
Log:
[S06] print default usage messag to standard output, by petition from avar++

Modified: docs/Perl6/Spec/S06-routines.pod
===
--- docs/Perl6/Spec/S06-routines.pod2010-06-10 20:20:37 UTC (rev 31188)
+++ docs/Perl6/Spec/S06-routines.pod2010-06-11 06:11:20 UTC (rev 31189)
@@ -3101,7 +3101,8 @@
 semicolon-style declaration that controls the whole file.
 
 If an attempted dispatch to C fails, the C routine is called.
-If there is no C routine, a default message is printed.  This
+If there is no C routine, a default message is printed to standard
+output.  This
 usage message is automatically generated from the signature (or
 signatures) of C.  This message is generated at compile time,
 and hence is available at any later time as C<$?USAGE>.